x cd /pub/data/acs2008/Tools; %let pgm=create_allgeos; filename pgm "&pgm..sas"; *---Modeled after cnvt_geo_files setup from last year (acs2007/Tools). This year we do not go back to the raw ascii files from the Bureau. Instead, we access a sas data set created by Billy E on the other (Windows) platform and use it as the source of the geographic data, but then adding our own customizations. *** Once this job is successfully completed edit and run the create_basetbls job to complete creation of the basetbls datasets by merging the basetables datasets uploaded to the temp library with this acsXXXX.allgeos dataset. *** jgb, 9-09 12-08-08: Added code to do keyed lookup on georef.cbsacos to get cbsa, cbsatype and metrodiv assigned to 050 levels. ---*; %let period=3yr; %let subdir=%str(3yr/); %let period=%str(); %let subdir=%str(1yr/); %let year=2008; %let yr=%substr(&year,3,2); %let yearm1=%eval(&year-1); title "&pgm.: Convert &year &period Geographic headers Data"; libname acs&year "/pub/data/acs&year"; *<====; libname acs&yearm1 "/pub/data/acs&yearm1"; *<====; libname temp '/pub/data/temp'; libname georef '/pub/data/georef' access=readonly; data allgeos. ***infile "/pub/data/acs2008/geos/&subdir.*.txt" truncover lrecl=415; length SumLev $3 geoid $20 Name $120 AreaName $100 Geocomp_Name $64 State Stab $2 SumLev $3 Geocomp $2 LogRecno 8 County $5 CBSA $5 cbsaType $5 UA $5 PlaceFP $5 PUMA5 $5 sdelm sdsec sduni $5 Region Division $1 CongDist $2 MetroDiv $5 CSA $3 NECTA $5. ; cbsaType=' '; CBSAYr=' '; *<--being retained because we did a keyed read below--; *** input @7 Stab $2. SumLev $3. Geocomp $2. LogRecNo 7. +1 Region $1. Division $1. @26 state $2. _cnty $3. cousubfp $31-35 placefp $36-40 cbsa $76-80 metrodiv $84-88 csa $81-83 necta $91-95 ua $104-108 CongDist $114-115 puma5 $166-170 @138 (sdelm sdsec sduni)($5.) @176 geoid $20. @216 Name $120.; *<----following sas data set was uploaded from P:\mcdc\acs2008\basetbls ---; set temp.allgeos&period(drop=fileid US statece tract blkgrp concit aia: aits anrc macc memi cneta nectadiv uacp sld: vtd zcta: submcd pci taz uga rename=(stusab=stab sumlevel=SumLev component=geocomp county=_cnty cousub=cousubfp place=placefp cdcurr=congdist areaname=name)); ***if state=' ' then state=_state2; if state='00' then state=' '; if stab=' ' and state=' ' then delete; length Geocode $12; geocode=substr(geoid,8); *---the codes identifying the area without SumLev and Geocomp and "US" from geoid-; if _cnty ne ' ' then County=State||_cnty; else County=' '; if geocomp ne '00' then do; Areaname=scan(name,1,';'); Geocomp_Name=scan(Name,2,';'); end; else Areaname=name; if state='29' and sumlev='795' then Areaname=puma5||' '||put(puma5,$mopuma.); *<---substitute names for the MO pumas---; if sumlev='050' then do; set georef.cbsacos(keep=county cbsa cbsatype MetroDiv Year rename=(year=CBSAyr)) key=county; if _iorc_ then _error_=0; else _cbsayr=CBSAyr; retain _cbsayr; end; else if cbsa ne ' ' then do; if index(areaname,'Micropolitan') then cbsatype='micro'; else cbsatype='metro'; cbsayr=_cbsayr; end; if stab='PR' and state=' ' then state='72'; *<---this little glitch caused grief so we fix it here---; label CongDist='110th (2008) Congressional District'; label sumlev='Geog Summary Level' Geocomp='Geog Component' name=' ' stab=' '; drop _: ; run; proc sort out=acs2008.allgeos&period(index=(state) label="Geograpgy for ACS &period Data &year"); by geoid; ***by State Logrecno; run; proc freq data=acs2008.allgeos. table state sumlev; format state $state. sumlev $sumlev.; table state*stab/list missing; run; options ls=160; proc print data=acs2008.allgeos&period (where= (state in('10','29')) drop=name geocomp_name); by state; id logrecno geoid; run; *---See what has changed since last year---; data different; merge acs&yearm1..allgeos(keep=geoid areaname geocomp in=inlast) acs&year..allgeos(keep=geoid areaname geocomp in=inthis); by geoid; if not (inlast and inthis); if inthis then Year="&year"; else Year="&yearm1"; run; proc print data=different; title2 "Different: Geographies that Came or Went Since &yearm1"; id geoid; /* =======================Begin comment================ *----Run this check step to see what geographies may be missing or surprising------; data acs2008.geo_anomalies; merge acs2008.allgeos(in=in1) acs2008.allgeos3yr(in=in3); by geoid; length default=3; if in1 and not in3 then Anomaly='In 1-Year but not in 3-yr'; if sumlev='795' and not in1 then Anomaly='PUMA not in 1-Yr'; if anomaly ne ' '; In1Yr=in1; In3Yr=in3; run; proc sort; by anomaly state; run; proc print data=acs2008.geo_anomalies; by anomaly state; title2 'Anomalies in the Two allgeos Data Sets'; run; ======================End comment================== */