x cd /pub/data/stf903x/Tools; %let pgm=new_versions; filename pgm "&pgm..sas"; *--create alternate versions of the stf903x.moi, .ksi, .ili and .us datasets with updated geocodes. We rename the previous versions with suffix "old", e.g. stf903x.moi_old and stf903x.us_old. Adapted from setup of the same name in the stf901x/Tools library. Apr. 2002 per note from Yu Li. Instead of replacing the existing sets and renaming previous versions to _old we call the edited versions _new for now. Will probably rename later. ----; libname stf903x '/pub/data/stf903x'; %macro doit(set); data stf903x.&set._new(index=(SumLev)); length State $2 GeoCode $16 default=4 PlaceFP CouSubFP $5; set stf903x.&set (rename=(slvl=SumLev)); slvl=SumLev; *--the following select group assigns the variable geocode based on values of slvl. note that it is critical that this code be consistent with that used in stf801x conversion so that we can match the data sets on geocode and slvl.; if state=' ' and sumlev='040' then state=geocode; if place ne ' ' then do; if place='9999' then placefp='99999'; else do; length _arg $6; _arg=state||place; placefp=substr( put(_arg,$plccnvt7.), 3,5); end; end; if cousubce ne ' ' then do; length _arg2 $8; _arg2=county||cousubce; cousubfp=substr( put(_arg2,$mcdcnvt7.), 3,5); end; drop _arg _arg2; select (sumlev); when('040') do; geocode=state; end; when('050') do; geocode=county; end; when('060','061','062') do; sumlev='060'; geocode=county||'-'||cousubfp; end; when('155') do; geocode=county||'-'||placefp; end; when('160','161') do; sumlev='160'; geocode=state||'-'||placefp; end; when('140') do; geocode=county||'-'||tract; end; when('150') do; geocode=county||'-'||tract||'-'||bg; end; when ('340') do; geocode=state||'-'||msacmsa||placefp; end; when('500') geocode=state||'-'||cd; otherwise ; end; run; proc freq data=stf903x.&set._new(keep=SumLev); table sumlev; format sumlev $sumlev.; title2 "Frequency of sumlev on new stf903x.&set"; run; %mend doit; %doit(moi); %doit(us); %doit(ili); %doit(ksi); /*<=========================Comment out===================================== ===========================End commented out================================ */