x cd /pub/data/mable2k/Tools; %let pgm=tiger_codes; filename pgm "&pgm..sas"; *--Read the tiger 2000 "ua" files to get additional geocodes for mable2k---; *---Note: See setup of the same name in the tigerua/Tools directory to see more extensive reading of the tiger/line files. We discovered a much shorter way to get what we want for our immediate mable2k purposes--; *--John Blodgett, May, 2002. --*; libname mable2k "/pub/data/mable2k"; libname user "/SAS_temp/user"; filename cnvtlog '/pub/data/mable2k/tigercodes.log'; *<--messages written here documenting conversion--; *filename in1 pipe "unzip -pa /pub/data/tigerua/TGR&fipco..ZIP TGR&fipco..RT1"; *filename Iin pipe "unzip -pa /pub/data/tigerua/TGR&fipco..ZIP TGR&fipco..RTI"; %macro doit(fipco,cnytname); %*--Macro to process a single county. We shall then use the docos utility macro to do the entire state--; filename Ain clear; filename Cin clear; filename Sin clear; filename Ain pipe "unzip -pa /pub/data/tigerua/TGR&fipco..ZIP TGR&fipco..RTA"; filename Cin pipe "unzip -pa /pub/data/tigerua/TGR&fipco..ZIP TGR&fipco..RTC"; filename Sin pipe "unzip -pa /pub/data/tigerua/TGR&fipco..ZIP TGR&fipco..RTS"; data acodes; infile Ain lrecl=98; input rt $1. cenid $11-15 polyid 16-25 puma5 $60-64 ua $81-85; if rt ne 'A' then do; put 'Record type is not A! --- aborting...' / _all_; list; stop ; end; if _error_ then do; file log; put "***Abending due to error condition trying to read the RTA file for state &stab, county &fipco" /_all_; list; file cnvtlog mod; put "***Abending due to error condition trying to read the RTA file for state &stab, county &fipco"; abort abend; end; drop rt; run; proc sort; by cenid polyid; run; data scodes; infile Sin lrecl=120; input rt $1. cenid $11-15 polyid 16-25 water $26 county $47-51 cousubfp2 $57-61 placefp2 $67-71 tractin $72-77 block $78-81 ur $119 ur90 $120; if rt ne 'S' then do; put 'Record type is not S! --- aborting...' / _all_; list; stop ; end; length tract $7; tract=substr(tractin,1,4)||"."||substr(tractin,5,2); if placefp2=' ' then placefp2='99999'; drop tractin rt; run; proc sort data=scodes; by cenid polyid; run; data sa; merge scodes acodes; by cenid polyid; run; proc sort data=sa nodupkeys; by county tract block ua puma5 ur; run; proc append data=sa base=mable2k.&stab.blks2; run; data cnames; infile Cin lrecl=112; input rt $1. county $6-10 datayr $4. fips $char5. fipscc $2. placedc $1. lsadc $2. entity $1. ma $4. sd $char5. aianhhce $char4. vtdtract $char6. ua $5. aitsce $char3. AreaName $60.; if entity not in('S','T'); run; proc append data=cnames base=mable2k.&stab.cnames; run; %mend doit; *docos(state=29,msgs=1); %macro doit_st(state,stab); %let n2=0; %reset(mable2k.&stab.blks2) *<--for start-overs this will erase any data in this set--; %reset(mable2k.&stab.cnames) *<---ditto-; %docos(state=&state,msgs=1) data _null_; if 0 then set mable2k.&stab.blks nobs=n1; if 0 then set mable2k.&stab.blks2 nobs=n2; file cnvtlog mod; call symput('n2',put(n2,7.)); put "&state&stab tigerua processing complete. &stab.blks2 has " n2 " observations." ; file stdout; put "&state&stab tigerua processing complete. &stab.blks2 has " n2 " observations." ; if n1 ne n2 then put "***Block Counts do not match for &stab . &stab.blks has " n1 "observations."; run; %if &n2=0 %then %do; data _null_; file cnvtlog mod; put "***aborting convert run because no blocks detected for mable2k.&stab.blks2"; abort abend; run; %end; %mend doit_st; *dostates(01 02 04 05 29,mac=doit_st,msgs=1); *dostates(06 08 09 10 11 12 13 15 16 17 18 19 20,mac=doit_st,msgs=1); *dostates(21 22,mac=doit_st,msgs=1); *dostates(23,mac=doit_st,msgs=1); *dostates(24 25 26 27 28 30 31 32 33 34 35 36 37 38 39 40,mac=doit_st,msgs=1); *dostates(41 42 44 45 46 47 49 50 51 53 54 55 56,mac=doit_st,msgs=1); %dostates(48,mac=doit_st,msgs=1);