I'm working on my first loop with a nested loop in Stata, but can't get the code to run.
Here is what I have:
*identify anti policies of contiguous states
forvalues yr = 1983/1993 {
foreach state in Alabama Alaska Arizona Arkansas California Colorado
Connecticut Delaware Florida Georgia Hawaii
Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland
Massachusetts Michigan Minnesota Mississippi
Missouri Montana Nebraska Nevada NewHampshire NewJersey NewMexico NewYork
NorthCarolina NorthDakota Ohio
Oklahoma Oregon Pennsylvania RhodeIsland SouthCarolina SouthDakota Tennessee
Texas Utah Vermont Virginia
Washington WestVirginia Wisconsin Wyoming {
gen 'st'_anti_'yr'=.
replace 'st'_anti_'yr'=1 if 'st'_c==1 & anti["st"_"yr"]==1
replace 'st'_anti_'yr'=0 if 'st'_c==0 | anti["st"_"yr"]==0
}
}
When I run the code, I get the error:
r(100) or r(100) { required
This error shows up no matter how I modify the code (adding or removing the ' or ", etc.).