x cd /pub/data/mable2k/Tools; %let pgm=cnvtsldblks; filename pgm "&pgm..sas"; *---Reads the state-level Geographic Header Record files, a State Legislative District Summary File Supplement as downloaded from the Census Bureau web site, Jan, 2007. We read and keep only the field needed to link the 2k census blocks with the "pre-2010" (but "post-2000") legislative district codes. New variables being added are: sldu02 sldl02 cd109 . (Other vars get read but then dropped. We were not sure if any of the other variables might have reflected changes but our test case in Colorado using Proc Compare indicated that no other fields had changed from what we already had.) Files are from: ftp2.census.gov: /census_2000/datasets/State_Legislative_Districts/SLD_Block_Supplement/ John Blodgett, OSEDA, U. of Missouri, January 17, 2007 Under contract with the Missouri Census Data Center. IMPORTANT NOTE: We have to run setup genmable2k_02.sas before these new variables get incorporated into the mable2k views (mov2, etc) as used in geocorr2k. <======================================================================== ---*; title "&pgm"; filename curpath '/pub/data/mable2k/sldblks'; libname mable2k '/pub/data/mable2k'; ** access=readonly; %let inpath=%str(/pub/data/mable2k/sldblks); *<===path (directory) where the input xx_geo_slb.zip files are stored---*; **libname sasout "&inpath"; *<===========output sas data sets stored is same dir as input files======; x cd &inpath; *<---make it the current directory--; %let stab=de; %let state=10; *<----Delaware for testing---; %let stab=co; %let state=08; %let statenme=Colorado; %let maxobs=99999999; %macro doit(state,stab); title2 "Processing State &state &stab &statenm"; filename geos pipe "unzip -a -p &stab.geo_slb"; data &stab.blks; infile geos missover lrecl=1024 obs=&maxobs; retain _first 1; drop _first; retain State "&state" Stab "&stab"; length County $5 Tract $7 Block $4; if _first then do; input FileId $char6. _stusab $2. @; retain FileId _stusab; drop fileid _stusab; if substr(FileId,2,3) ne 'SLD' then do; file log; put '******Problem with input geographic headers file. Did not find "SLD" in cols. 2-4 ' FileId= / '***Conversion will not run***'; list; stop; end; if _stusab ne upcase("&stab") then do; file log; put "******Problem with input geographic headers file. Did not find expected state abbrv &stab in 5-6 " FileId= / '***Conversion will not run***'; list; stop; end; end; input @30 State $2. Cnty $3. @56 TractIn $6. +1 Block $4. @136 UrbanRur $1. @139 (cd108 cd109 cd110)($2.) (sldu02 sldl02)($char3.) vtd $char6. vtdi $1. @158 ZCTA3 $3. ZCTA5 $5. @173 (AreaLand AreaWatr)(14.) @293 Pop100 9. HU100 9. IntPtLat 9.6 IntPtLon 10.6 @332 PartFlag $1. (SDElm SDSec SDUni)($5.) TAZ $6. UGA $5. PUMA5 $5. PUMA1 $5. ; if cnty ne ' ' then County=state||cnty; *--edit the tract so that it is in xxxx.xx format with leading and trailing zeroes--; if TractIn ne ' ' then Tract=translate( substr(TractIn,1,4)||'.'||substr(TractIn,5,2) ,'0',' '); drop tractin; *--Create land and total area values in square miles. --; LandSQMI=AreaLand/2589988; AreaSQMI=LandSQMI + (AreaWatr/2589988); format LandSQMI AreaSQMI 9.2; format IntPtLon 11.6 IntPtLat 10.6; *<--added 7-13-01-; label LandSQMI='Land Area Sq Mls' AreaSQMI='Total Area Sq Mls' AreaLand='Land Area Sq Meters' AreaWatr='Water Area Sq Meters'; label cd108='Cong District - 108th (2002)' cd109='Cong District - 109th (2004)' cd110='Cong District - 110th (2006)' sldu02='State Leg District Upper Chbr as of 2002' sldl02='State Leg District Lower Chbr as of 2002'; label ZCTA5='ZIP Census Tabulation Area'; *drop _: FileID; *drop cd110; *----Not filled in yet-----------------------; keep County Tract Block cd109 sldu02 sldl02 ; *<====Everything else we already have and the proc compare test for state of Colorado showed that none of the values changed----; run; proc sort data=&stab.blks out=mable2k.&stab.sldblks; by county tract block; run; *---See if any of our previously inserted codes (using TIGER files) have different values here---; ***proc compare base=mable2k.&stab.blks compare=sasout.&stab.sldblks outdif outnoequal out=outdif listobs nodate; *** id county tract block; *** run; data _null_; file stdout; put "Processing complete for &statenm"; run; filename geos clear; %mend doit; %***dostates(n=51,names=1,msgs=1) ; *---We had 4 states that failed on above try---; %dostates(01 11 28 53,names=1,msgs=1);