x cd /mscdc/data/corrlst/Tools; %let pgm=cnvt.bl90_bl2k; filename pgm "&pgm..sas"; *---Read the 1990 to 2000 census block correlation files created by Jim Harlan at GRC/MsDIS. The resulting SAS correlation list dataset, corrlst.mobl902k, will be used as a basis for creating other correlation lists and then allocating 90 data to 2k geography. jgb, 2-19-2001 rev. 3.05.01 to run with full input dbf file. ---*; filename corrdbf '/mscdc/data/corrlst/blkcorr.dbf'; libname corrlst v6 '/mscdc/data/corrlst'; libname mable v6 '/mscdc/data/corrlst/mable98' access=readonly; %libname (stf901x); libname user '/tmp/storage/user8'; title 'Creating corrlst.mobl902k: 1990 to 2000 Block Correlation List'; options ls=132 ps=120; /*<=========================Comment out===================================== proc dbf db4=corrdbf out=blkcorr; run; proc sort data=blkcorr; by blklnk90 blocklink; run; *---add the Pop90a variable to input (was on the test files sent by GRC but not the final).--; data pops90; set mable.mo29b(keep=cnty tract blk pop); length blklnk90 $13; *--same name and length as on the corrlst file--; blklnk90=cnty||trim(compress(tract,'.'))||blk; if substr(tract,6,2)='00' then substr(blklnk90,8,2)=' ' ; rename pop=pop90; drop cnty tract blk; run; ===========================End commented out================================ */ data blkcorr2(drop=county inmable) corrlst.nomb902k(label='Blks on GRC clist not on mable or no 2k blk'); merge blkcorr(in=inb rename=( blocklink=blklnk00 )) pops90(in=inm); by blklnk90; if substr(blk90,2,2)='99' then do; *--handle 1990 water blocks--; pop90=0; inm=1; end; if inb and inm and blklnk00 ne ' ' then do; output blkcorr2; return; end; else select (blklnk90); *--edit 3 cases per following note from Jim Harlan, GRC: John, Add these to the data file: blocklink=1650300014004 county=165 tract=030001 blkgrp=4 block=4004 tract90=030001 blk90=201 blklnk90=165030001201 xfactor=1 blocklink=1833111031016 county=183 tract=311103 blkgrp=1 block=1016 tract90=311103 blk90=203 blklnk90=183311103203 xfactor=1 blocklink=1892144004014 county=189 tract=214400 blkgrp=4 block=4014 tract90=2144 blk90=407A blklnk90=1892144 407A xfactor=1 ---*; when('165030001201') do; blklnk00='1650300014004'; _edit=1; end; when('183311103203') do; blklnk00='1833111031016'; _edit=1; end; when('1892144 407A') do; blklnk00='1892144004014'; _edit=1; end; otherwise _edit=0; end; if _edit=1 then do; county=substr(blklnk00,1,3); tract=substr(blklnk00,4,6); blkgrp=substr(blklnk00,10,1); block=substr(blklnk00,10,4); xfactor=1; put /_all_; output blkcorr2; end; else do; if inm then inmable='Y'; else inmable='N'; if not inb then county=substr(blklnk90,1,3); format county $mocnty.; _k+1; drop _k; if _k le 5 then put / _all_; output corrlst.nomb902k; end; drop _edit; run; proc print data=corrlst.nomb902k n; id blklnk90; title2 'corrlst.nomb902k: Problem Blocks'; title3 'Sorted by blklnk90 (1990 county, tract, block)'; title4 'Inmable=N Means the Block Could Not be Matched on the master 1990 Block file'; run; data corrlst.mobl902k(label='1990 Block - 2000 Blk corr. for MO'); retain state '29'; length County County90 $5 Tract Tract90 $7 BG bg90 $1 Block Block90 $4 Pop90a AFact 5; set blkcorr2; format county $county. Pop90a comma6. AFact 5.3; by blklnk90; County=state||substr(blklnk00,1,3); tract=substr(tract,1,4)||'.'||substr(tract,5,2); bg=blkgrp; county90=state||substr(blklnk90,1,3); if county ne county90 and first.blklnk90 then do; put '***County code changed:' blklnk90= blklnk00=; end; tract90=substr(blklnk90,4,4)||'.'||substr(blklnk90,8,2); tract90=translate(tract90,'0',' '); block90=substr(blklnk90,10,4); bg90=substr(block90,1,1); apop90= xfactor * pop90; blkpop90=pop90; *<====================New this run========================; pop90a=round(apop90); if xfactor < 1 then if blkpop90 > 0 then xfactor=pop90a/blkpop90; else xfactor=0; *--reasssign allocation factor after rounding; if xfactor > 1 then xfactor=1; *---Not sure why these factors over 1 are in there.--; afact=xfactor; *--we sum the rounded block intersection counts for each blocks. At the end we want to make sure our rounded values still total the block pop total-; if first.blklnk90 then _rsum=pop90a; else _rsum+pop90a; if last.blklnk90 and _rsum ne blkpop90 then do; *--see if the sum of the rounded pop90a values match the total for the 90 block. If not, adjust last block piece-; pop90a= pop90a + (blkpop90 - _rsum); if blkpop90 > 0 then xfactor=pop90a/blkpop90; else xfactor=0; end; keep state--afact; run; proc print label data=corrlst.mobl902k(obs=50); by county90; title2 'Sample Obs from Output corrlst set'; run cancel; proc sql; create table bgsums as select county90 as county, tract90 as tract, bg90 as bg, sum(pop90a) as totpopcl from corrlst.mobl902k(drop=county tract bg) group by county90, tract90, bg90 ; quit; data stf1pops; *--look for tracts where the 90 pop does not match the value we get by summing our corrlst entries; set stf901x.moi(keep=slvl county tract bg totpop); where slvl='150'; run; *---in run of 3-9-01 the set checks was empty -- all bgs checked!----------------------------*; data checks; merge bgsums(in=incorr) stf1pops(in=inmable); by county tract bg; if not incorr then flag='****Not in correlation list*******************'; else if not inmable then flag='******Not in STF1****************'; else if totpopcl ne totpop then flag='*******Pop sums don''t match*******'; if flag ne ' '; run; proc print data=checks; title2 'Block Groups With Possible / Probable Errors: Corr List pops do not match stf1 at BG level'; run;