Hi all, I'm a SAS beginner and have been struggling with the following problem for a few days now. I have a table with 4 variables: State, County, Poverty Density (PovDensity), Median Poverty Density(Median_Poverty_Density) and what I want to do is create a new character variable PovStatus with levels "Above State Median", "Below State Median"and "State Median" depending on whether each county's poverty density is above, below or equal to the state median poverty density. Now, my set contains three States: Alabama, Arkansas and Arizona but each of them has a bunch of different counties. Here is my code so far for Alabama: Data Med1;
Set MergedTables;
where state="Alabama";
run;
proc print data=Med1;
run;
data Med2;
set Med1;
if PovDensity>10.287 then
PovStatus="Above State Median";
else if PovDensity<10.287 then PovStatus="Below State Median";
else if PovDensity=10.287 then PovStatus="State Median";
run;
proc print data=Med2;
run; It works but I don't think I'm supposed to be doing it like this for each state separately, instead I want something that checks these conditions at once for all three states and gives me the correct results. I would greatly appreciate any feedback/suggestions for how I might achieve that. Thank you!
... View more