I'm a stata novice, and I've searched and tried things I've found, but I just can't figure this out. I am trying to make a scatter plot for each state. I was able to do it by using the number associated with each state (Alabama = 1, Alaska =2, etc) by using
So the above was a success, but I would like to save using state names instead.
I have tried
To which I receive a type mismatch error. or I try
and am told twoway is not a valid command name.
Here is the stata output:
Thank you for any help!
Code:
forvalues i = 1/51 { twoway (scatter edge percentFRL if state_num == `i', mcolor(blue%50) msize(tiny)), ytitle(Percent SIDE Neighborhood Poverty) ylabel(#5, angle(horizontal)) ymtick(##1) xtitle(Percent Students Free and Reduced Price Lunch) xlabel(#5, angle(horizontal)) xmtick(##1) title(`i') legend(off) graph save `i'.gph, replace }
So the above was a success, but I would like to save using state names instead.
I have tried
Code:
levels state, local(states) local i = 1 foreach s of local states { twoway (scatter edge percentFRL if state = `"s"', mcolor(blue%50) msize(tiny)), ytitle(Percent SIDE Neighborhood Poverty) ylabel(#5, angle(horizontal)) ymtick(##1) xtitle(Percent Students Free and Reduced Price Lunch) xlabel(#5, angle(horizontal)) xmtick(##1) title(`"s"') legend(off) graph save `"s"'.gph, replace }
Code:
levels state, local(states) local i = 1 foreach s of local states { twoway (scatter edge percentFRL if state = `"s"', mcolor(blue%50) msize(tiny)), ytitle(Percent SIDE Neighborhood Poverty) ylabel(#5, angle(horizontal)) ymtick(##1) xtitle(Percent Students Free and Reduced Price Lunch) xlabel(#5, angle(horizontal)) xmtick(##1) title(`"s"') legend(off) graph save '=strtoname("'s'").gph, replace }
Here is the stata output:
Code:
levels state, local(states) `"Alabama"' `"Alaska"' `"Arizona"' `"Arkansas"' `"California"' `"Colorado"' `"Connecticut"' `"Delaware"' `"District Of Columbia"' `"Florida"' `"Georgia"' `"Hawaii"' `"Idaho"' `"Illinois"' `"Indiana"' `"Iowa"' `"Kansas"' `"Kentucky"' `"Louisiana"' `"Maine"' `"Maryland"' `"Massachusetts"' `"Michigan"' `"Minnesota"' `"Mississippi"' `"Missouri"' `"Montana"' `"Nebraska"' `"Nevada"' `"New Hampshire"' `"New Jersey"' `"New Mexico"' `"New York"' `"North Carolina"' `"North Dakota"' `"Ohio"' `"Oklahoma"' `"Oregon"' `"Pennsylvania"' `"Rhode Island"' `"South Carolina"' `"South Dakota"' `"Tennessee"' `"Texas"' `"Utah"' `"Vermont"' `"Virginia"' `"Washington"' `"West Virginia"' `"Wisconsin"' `"Wyoming"' local i = 1 foreach s of local states {scatter edge percentFRL if state = `"s"', mcolor(blue%50) msize(tiny), ytitle(Percent SIDE Neighborhood Poverty) ylabel(#5, angle(horizontal)) ymtick(##1) xtitle(Percent Students Free and Reduced Price Lunch) xlabel(#5, angle(horizontal)) xmtick(##1) title(`"s"') legend(off) graph save '=strtoname("'s'").gph, replace }
Comment