x cd /pub/data/stf901/Tools; %let pgm=moblks00_urbanrural; filename pgm "&pgm..sas"; *--Coded by John Blodgett, OSEDA, Nov 2001. Under contract with Mo Census Data Center. Table p4 on 1990 Summary File 1 had data regarding the urban,rural, urbanized area population. However, because it takes some time to define Urbanized Areas based on the census results, the data get published with these items left blank for STF files (at least the a and b series). What we are doing here is filling in these items using the mable98 data base, which is based on the Bureau ZIP_Block equivalency file, 1990. The data set created here is stf901.moblks00_urbanrural . It contains 1990 population counts allocated to 2000 census block geography. It is designed to be an easy merge/update partner to stf901.moblks00. The data sets generated here involve converting from 1990 census geography to 2000 geography using a 1990 to 2000 Missouri block correlation list as created in cnvt.bl90_bl2k.sas in corrlst/Tools. --*; libname stf901 '/pub/data/stf901'; libname user '/SAS_temp/user'; libname corrlst '/pub/data/corrlst' access=readonly; %libname(mable98); libname sf12000 '/pub/data/census_2000/sf12000' access=readonly; options compress=yes; %macro stopit; %*<===============macro inserted in 2 steps below to stop processing during testing===; *if county gt '29003' then stop; %mend stopit; *---Step 1: Create the 1990 data using mable98 block level data set----; data urblks90; length state $2 county $5 tract $7 bg $1 blk $4; merge mable98.mo29b(in=inbase keep=drop=x1obs intptlat intptlng tract80 x1obs ) mable98.mo29x2(in=inx2 keep=x2obs county urbanrur urbarea); by x2obs; %stopit; if not (inbase and inx2) then do; put '***Logic Problem: Missing data for this block: ' _all_; _nbad+1; if _nbad ge 100 then abort abend; drop _nbad; delete; end; length default=4; length UrbanPop90 UrbanHUs90 UrbanLand90 5 p4i1-p4i3 h4i1-h4i3 4; label UrbanPop90='Pop in Urban Areas, 1990' UrbanHus90='Housing Units in Urban Areas, 1990'; label p4i1='Persons: in Urbanized Area' p4i2=': Urban, not in Urbanized Area' p4i3=': Rural' h4i1='Housing Units: in Urbanized Area' h4i2=': Urban, not in Urbanized Area' h4i3=': Rural' UrbanLand90='Urban Land Area Sq Miles, 1990'; if urbanrur='1' then do; *--It is an urban block--; urbanpop90=pop; urbanhus90=hus; if urbarea='9999' then do; p4i1=pop; h4i1=hus; p4i2=0; h4i2=0; end; UrbanLand90=.3860342* arealand; *--convert to sq miles from sq kms--; p4i3=0; h4i3=0; end; else do; *--its rural--; urbanpop90=0; urbanhus90=0; p4i1=0; h4i1=0; p4i2=0; h4i2=0; UrbanLand90=0; p4i3=pop; h4i3=hus; end; run; *--create data to be aggregated by joining the mable-based block level data with the blk correlation list-; data aggin(drop=pop90a notin compress=yes) nomatch(keep=county tract90 block90 pop90a UrbanPop90 UrbanLand90 notin compress=no); length notin $7 ; merge urblks90(in=indata rename=(tract=tract90 blk=block90) ) corrlst.mobl902k(in=inclist where=(substr(block90,2,2) ne '99')); by county tract90 block90; %stopit; if not (inclist and indata) then do; if inclist then notin='MABLE '; else notin='CORRLST'; if pop90a then output nomatch; *--if it is in clist and there is no pop to be allocated forget it-; return; end; output aggin; label tract='Tract 2000' block='Block 2000'; keep notin pop90a county tract90 block90 tract block afact p4i1-p4i3 h4i1-h4i3 UrbanLand90 UrbanPop90 UrbanHUs90 ; run; proc sort data=aggin; by county tract block afact; run; options msglevel=n ; %agg(aggin=aggin,aggout=aggout,aggby=county tract block,agglvls=1,grand=0, aggvars=UrbanLand90 UrbanPop90 UrbanHUs90 p4i1-p4i3 h4i1-h4i3, facvar=afact,dropvars=afact _nag_ _lvl_) ; run; data stf901.&pgm (label='1990 Urban/Rural counts by 2000 census blks' compress=yes sortedby=county tract block index=(county)); length TotPop90 TotHUs90 4 county $5 tract $7 block $5 Urban InUA $1; set aggout; format county $mocnty.; label tract='2000 census tract' block='2000 census blk' Urban='In Urban Area?' InUA='In Urb Area?'; array counts(*) p4i1-p4i3 h4i1-h4i3 UrbanLand90 UrbanPop90 UrbanHUs90 ; TotPop90=sum(of p4i1-p4i3); TotHUs90=sum(of h4i1-h4i3); if UrbanPop90 = Totpop90 or UrbanPop90 > .5*TotPop90 then Urban='1'; else Urban='0'; if p4i1 = Totpop90 or p4i1 > .5*TotPop90 then InUA ='1'; else InUA ='0'; format TotPop90 TotHUs90 5. p4i1-p4i3 h4i1-h4i3 5.1 UrbanLand90 7.4 UrbanPop90 UrbanHUs90 5. ; run; proc print data=stf901.&pgm(obs=40); title2 "First 40 Obs on stf901.&pgm"; by county tract; id block; run; *----verify that populations add up-------------*; proc tabulate data=stf901.&pgm; class county Urban InUA; var UrbanPop90 p4i3 UrbanHUs90 h4i3 UrbanLand90 ; table all='Missouri Totals' County Urban InUA, (UrbanPop90 p4i3 UrbanHUs90 h4i3 )*sum=' '*f=comma10. UrbanLand90*sum=' '*f=8.3 ; title2 'Proc Tabulate Report With State and County Aggregation'; run;