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 }
0 Response to loop for graphs
Post a Comment