x cd /pub/data/mable2k/Tools; %let pgm=tiger_codes108_fix46007; filename pgm "&pgm..sas"; *--This is a special rerun of the logic of the tiger_codes108 setup. Here all we read is data for Bennett co, SD (FIPS code 46007). We read the data and do a custom update of dataset mable2k.sdblks2a. This dataset had no obs for Bennett, which can be traced back to a problem with the sdblks2 dataset, where the county was also missing. So when we apply the update step here we do NOT require that the update block match one in the previous (sdblks) dataset. JGB, 9-9-06. 12-13-06: Try again. We fixed the PUMA but we still do not have any Bennett co data in the sdblks2 dataset and this causes variables such as ur, ur90, cousubfp2 and placefp2 to be missing in sdblks2a and then (most importantly) in the sdv2 view (which refs sdblks2a). Here we go back to the orginal tigerua files for 46007 to read those items. ---; libname mable2k "/pub/data/mable2k"; libname user "/SAS_temp/userb"; filename cnvtlog '/pub/data/mable2k/tigercodes108.cnvtlog'; *<--messages written here documenting conversion--; %let state=46; %let stab=sd; %let fipco=46007; *------------------Step added 12/06 to read the old tigerua files and update mable2k.sdblks2. Much of this code was taken from tiger_codes.sas, which reads the tigerua files from circa 2002 ----------------*; filename Ain1 pipe "unzip -pa /pub/data/tigerua/TGR&fipco..ZIP TGR&fipco..RTA"; filename Sin1 pipe "unzip -pa /pub/data/tigerua/TGR&fipco..ZIP TGR&fipco..RTS"; data acodes; infile Ain1 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 Sin1 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; *---adding this new data for Bennett county to the old mable2k.sdblks2 dataset--------; data mable2k.sdblks2fixed; *<----rename this dataset later to replace the original sdblks2 dataset--; set mable2k.sdblks2 sa; by county tract block; *--interleaving will insert it at the correct location within the datawset--; run; *--------------------This completes the NEW portion of this run for Decembmer 06. We have to rerun the old steps, modified to point to this updated blks2 dataset---------------------; %macro doit(fipco,cnytname); %*--Macro to process a single county.--; filename Ain clear; ***filename Cin clear; filename Sin clear; filename Ain pipe "unzip -pa /pub/data/tiger108/tgr&fipco..zip TGR&fipco..RTA"; *filename Cin pipe "unzip -pa /pub/data/tiger108/tgr&fipco..zip TGR&fipco..RTC"; filename Sin pipe "unzip -pa /pub/data/tiger108/tgr&fipco..zip TGR&fipco..RTS"; %*--set spbflag flag to id the few counties in the US where a cd108 splits blocks. We have to select the appropriate block in these cases per the list of which-block-to-use at http://www.census.gov/geo/www/tiger/tgrcd108/spblk108.txt . ; %let spltcos=18003 18029 18039 18067 18081 18097 21011 21111 21209 42003 42011 42041 42045 42051 42069 42079; %let spltcos=&spltcos. 42091 42101 42125 42129 55015 55105; %if %index(&spltcos,&fipco) %then %let spbflag=1; %else %let spbflag=0; %if &spbflag %then %put ***Program will look for split blocks while processing county &fipco *****; data acodes; infile Ain lrecl=98; input rt $1. cenid $11-15 polyid 16-25 cd108 $53-54 puma5 $60-64 ua90 $86-89 ; ****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; *---Only read what we need-----*; input rt $1. cenid $11-15 polyid 16-25 county $47-51 tractin $72-77 block $78-81 ur00cor $82 ua00cor $103-107 ua90red $108-112 ur90red $113 ; * 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; label ur00cor='Urban Rural Indicator 2000, Corrected' ua00cor='Urban Area Code 2000, corrected' ua90red='Urban Area Code, 1990 redfined on Census 2000 Criteria' ur90red='Urban/Rural Indicator, 1990 redefined on Census 2000 Criteria'; 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 cd108 puma5 ur00cor ua00cor ; run; %mend doit; options mprint; %doit(46007,%str(Bennett, SD)); *----Apply the new dataset as an update to the old &stab.blks2 dataset----; data mable2k.sdblks2afixed(label='With tiger108 updates applied (revised version)'); update mable2k.sdblks2fixed(in=inblks2) sa(in=in108) end=last; by county tract block; if first.county then put county= inblks2= ; run; *<===!!!!!!!==When we verify that the update was successful we shall delete the orginal sdblks2a dataset and then rename this new one to be the sdblks2a. We can do this interactively-------------------------------; proc freq data=mable2k.sdblks2afixed; table county; run;