Hi,
I have the data below.
Where population is >=15 and <=25, if there are any pct values >=96, I need to replace the pct value with a 96+ and the associated number value with a --.
Where the population is >=26 and <=99, if there are any pct values >=97, I need to replace the pct value with a 97+ and the associated number value with a --.
Where the population is >=100, if there are any pct values >=99, I need to replace the pct value with a 99+ and the associated number value with a --.
I have the SAS code below.
A few questions:
1) Did I do this right?
2) When I export to MS Excel and use find/replace (i.e, find -1 and replace with --), why do I come up with 4 more values of -1 than the combined count of -2, -3, and -4? I tried filtering in Excel just for the -1 values to see if the 4 extra -1's didn't have matching -2 or -3 or -4 but I couldn't find any of the extra -1's.
a) Therefore, how do I find any -1 in the SAS dataset (which is only in the num column) that doesn't have a matching -2 or -3 or -4 value?
b) Why do I have 4 extra -1's?
c) How can I double check I am getting what I want to get?
Thanks!
data have;
input buildingname & $20. population numvax1 pctvax1 numvax2 pctvax2 numvax3 pctvax3 buildingtype $;
cards;
happy days 100 99 99 96 96 100 100 private
learning tree 20 18 90 18 90 19 95 public
bean stalk 50 50 100 50 100 50 100 public
;
proc format;
value pct
-2="96+"
-3="97+"
-4="99+";
value nm
-1="--";
run;
data want;
set have;
if population >=15;;
array pcts{*} pct_:;
array nums{*} num_:;
do i=1 to dim(pcts);
if 15=<population<=25 and pcts{i}>=96then nums{i}=-1;
if 15=<population<=25 and pcts{i}>=96 then pcts{i}=-2;
if 26=<population<=99 and pcts{i}>=97 then nums{i}=-1;
if 26=<population<=99 and pcts{i}>=97 then pcts{i}=-3;
if population>=100 and pcts{i}>=99 then nums{i}=-1;
if population>=100 and pcts{i}>=99 then pcts{i}=-4;
end;
format pct_: pct.;
format num_: nm.;
run;
... View more