x cd /pub/data/sf12000x/Tools; %let pgm=XXmsas00; filename pgm "&pgm..sas"; *----Create sf1x.XXmsas00 data set with summaries for MSAs as defined on census day 2000 for various states. (Here "XX" is a state postal abbreviation and we create sets in the sf12000x directory with names of the form XXmsas00 as used in the dp1_2k.sas web application. John Blodgett, Initial coding Nov. 10, 2001. ----*; libname user '/SAS_temp/user'; libname sf12000 '/pub/data/census_2000/sf12000' access=readonly; libname sf12000x '/pub/data/sf12000x'; libname sf1x (sf12000x); *--alternate libref--; *let stab=ks; %macro doit(stab); data msacntys; *--because we did not keep the msacmsa code on the sf1x data set (dumb!!!)---; set sf1.&stab.geos(keep=sumlev county msacmsa); where sumlev='050' and msacmsa ne '9999'; drop sumlev; run; data meansin; merge sf12000x.&stab.i(keep=sumlev state county geocode totpop90 in=indata where=(sumlev='050')) msacntys(in=inmsa); by county; if inmsa and indata; ***put / _all_; geocode=state||'-'||msacmsa; run; proc means data=meansin noprint; class geocode; types geocode; *--no grand totals--; var totpop90; output out=msapops90(drop=_type_ _freq_) sum=; run; data sf1x.&stab.msas00; length areaname $64 msacmsa $4; merge sf1x.&stab.i (in=in2k where=(sumlev='390')) msapops90(in=in90); by geocode; msacmsa=substr(geocode,4,4); if in2k; **if msacmsa in ('3760','7040') then areaname="&stab Portion of " || areaname; areaname=trim(areaname)||' (As defined for Census 2000)'; change=totpop - totpop90; if totpop90 then pctchange=100*change/totpop90; run; proc print data=sf1x.&stab.msas00; id geocode msacmsa areaname; var totpop totpop90 change pctchange; title "Partial Listing of sf1x.&stab.msas00"; run; %mend doit; %doit(ks); %doit(il);