x cd /pub/data/stf903x/Tools; %let pgm=ustracts; filename pgm "&pgm..sas"; *--Merge the stf903x subdirectory slv140.bystates datasets into a single set for US with the msacmsa and pmsa codes added-; libname user '/SAS_temp/user'; libname stf903x '/pub/data/stf903x'; libname corrlst '/pub/data/corrlst' access=readonly; libname tracts '/pub/data/stf903x/slvl140.bystate'; title "Create stf903x.ustracts: All Census Tracts in US"; /*<=========================Comment out===================================== data tracts; %macro doit(state,stab); tracts.&stab.tracts %mend doit; set %dostates open=defer; run; proc sort data=tracts; by state county; run; ===========================End commented out================================ */ data stf903x.ustracts(label='All tracts in US with metro codes added' compress=yes sortedby=state county); length state $2 county $5 CntyName $32 tract $7 msacmsa pmsa $4 reg div $1; merge tracts(in=int) stf903x.uscntys(in=inc keep=state county reg div msacmsa pmsa areaname rename=(areaname=CntyName)); by state county; format county $5.; if not (inc and int) and first.county then do; put '***Missing data for ' state county cntyname ; delete; end; output; run; *---Another pass here to get the metro area codes for new england tracts---; data stf903x.ustracts; merge stf903x.ustracts(in=in1) corrlst.netr2ma90(in=in2 drop=totpop90); by county tract; format county $5.; run; proc datasets library=stf903x nolist; modify ustracts; index create msacmsa; index create metro=(msacmsa pmsa); index create statemet=(state msacmsa pmsa); run; proc print data=stf903x.ustracts(where=(msacmsa='7000') keep=_character_ totpop); by state county; title2 'Partial Listing: All Obs Using Filter: where msacmsa="7000" '; sum totpop; run; proc tabulate data=stf903x.ustracts; class msacmsa county cntyname pmsa; var totpop; where msacmsa ne '9999' and msacmsa ne '####'; table msacmsa*(all='Metro Totals' county*cntyname), totpop=' '*(N='# Tracts'*f=comma8. sum='1990 Population'*f=comma12.); title2 'Counties in Metro Areas From 1990 Census'; run;