x cd /pub/data/stf903/Tools; %let pgm=mosl090_00; filename pgm "&pgm..sas"; *--This is the final and correct version of this project. Ignore create_mobg090_00.sas-------; *--Coded by John Blodgett, OSEDA, May 2002. Under contract with Mo Census Data Center. Aggregate/convert 1990 full stf3 data set at the (1990) split-bg (slvl=090) level to create mosl090_00 with the same tables but aggregated to 2000 split block group (SumLev=090) geography. We also create summaries at the 2000 complete block group (SumLev=150), and Census Tract (140) levels. The data sets generated here involve converting from 1990 census geography to 2000 geography using a 1990 to 2000 Missouri split-BG correlation list as created in sbg90_sbg2k.sas corrlst/Tools. --*; libname stf903 '/pub/data/stf903'; libname user '/SAS_temp/user'; libname corrlst '/pub/data/corrlst' access=readonly; %let sl90vars=county tract bg UrbanRur cousubfp placefp ; *<----Defines SORT ORDER of OUTPUT set!--; /*<=========================Comment out===================================== *--create data to be aggregated by joining the 1990 split-bg (090) level data with the correlation list-; data aggin(drop=pop90a notin county90 cousubfp90 placefp90 tract90 urbarea90 urbanrur90 cd90 bg90 compress=yes) unmatched(keep=county90 cousubfp90 placefp90 tract90 urbarea90 urbanrur90 cd90 bg90 pop90a p1i1 h1i1 notin); *--match the stf3 90 blocks with the corr list to attach the 2000 geocodes, i.e. tract and block; length notin $7 ; length default=5; retain SumLev slvl '090'; merge stf903.mosl090(keep=county cousubfp placefp tract urbarea urbanrur cd bg _numeric_ %renamel(county cousubfp placefp tract urbarea urbanrur cd bg,90) in=instf3 ) corrlst.sbg90_sbg2k(in=inclist); by county90 cousubfp90 placefp90 tract90 urbarea90 urbanrur90 cd90 bg90; if not (instf3 and inclist) then do; if instf3 and p1i1 = 0 then delete; if not instf3 then notin='stf3090'; else notin='corrlst'; _nbad +1; if _nbad gt 10 then stop; drop _nbad; put / '*** ' _all_; output unmatched; delete; end; output aggin; run; proc datasets library=user nolist; modify aggin; index create sl90= (&sl90vars); quit; ===========================End commented out================================ */ *----We use the module in sascode(agg903.sas) to do the aggregation, but we have to assing the global parms used by that module so it knows where things come from and go to. ----*; %let _aggin=aggin; %let _aggout=aggout; %let _aggby=&sl90vars; %let _grand=1; %let _agglvl=6; %let _idvars=SumLev; %let _facvar=afact; %include '/pub/sascode/agg903.sas'/source2; *<---include standard sas code to do the actual aggregation based on all the global parms just assigned----; drop areaname; run; data stf903.mobgs00(label='1990 stf3 tables by 2000 census block grps' drop=cousubfp placefp UrbanRur compress=yes sortedby=county tract bg) stf903.motrs00(label='1990 stf3 tables by 2000 census tracts' drop=cousubfp placefp UrbanRur bg compress=no sortedby=county tract) stf903.mosl090_00(label='1990 stf3 tables by Split BG 2000' compress=yes sortedby=&sl90vars) cksums(label='State totals and county generated as checks'); length sumlev $3 county $5 tract $7 bg $1 UrbanRur $1 cousubfp placefp $5 geocode $32; ***merge mogeos(in=ingeos) aggout(in=inagg) ; set aggout; select (_lvl_); when(1) do; sumlev='090'; geocode=%concatd(county,cousubfp,placefp,tract,urbanrur,bg); output stf903.mosl090_00; end; when(2,3) delete; when(4) do; sumlev='150'; geocode=%concatd(county,tract,bg); output stf903.mobgs00; end; when(5) do; sumlev='140'; geocode=%concatd(county,tract); bg=' '; output stf903.motrs00; end; when(6) do; sumlev='050'; geocode=county; output cksums; end; when(99) do; sumlev='040'; geocode='29'; output cksums; end; otherwise do; put /'***Unexpected value for _lvl_ code: ' _lvl_= / _all_; delete; end; end; *--select--; drop _lvl_ afact; run; *----verify that populations add up-------------*; *---This step ran successfully from DM and verified pop counts, 8-6-01 14:50 ---; data popcks; set stf903.mosl090_00(keep=sumlev county p1i1) stf903.mobgs00(keep=sumlev county p1i1) stf903.motrs00(keep=sumlev county p1i1) cksums(keep=sumlev county p1i1); run; proc tabulate data=popcks; class sumlev county; var p1i1; table (all county) * sumlev, p1i1='Total Pop 1990' *sum*f=comma12.; title2 'Summary Checks to Verify Pop Totals on Aggregated Data Sets'; run;