x cd /pub/data/acs2005/Tools; %let pgm=geography; filename pgm "&pgm..sas"; *----Read the Geography.txt file released with Wave 1 tables. Creates the acs2005.geocodes dataset. John Blodgett, OSEDA as part of Missouri Census Data Center contract. Aug, 2006. ----*; %let year=2005; filename in '../Geography.txt'; libname acs2005 "/pub/data/acs2005"; libname acs (acs&year); *<---create alias name---; data acs.geography(label='Geographic IDs for Wave 1 tables' sortedby=sumlev compress=yes); infile in firstobs=2 truncover; length GeographyID $19 Name $100 AreaName $80 Geocomp_name $64; length Geocode $16; length SumLev $3 Geocomp $2 State $2 Stab $2 County $5 Region Division $1 cbsa $5 cbsaType $5 MetroDiv $5 CSA $3 NECTA $5 placefp $5 cousubfp School UA puma5 $5 CongDist $2 OTSA $4; label cbsa='Core based Stat Area' metrodiv='Metropolitan Division' CSA='Combined Statistical Area' necta='New England City & Town Area' UA='Urbanized Area' congdist='Congressional District (109th)' otsa='Am Indian Area/Alaska Nat Area/Hawn Home Land'; input GeographyId Name $88.; _id=GeographyId; _gcode=substr(_id,8); Geocode=_gcode; SumLev=substr(geographyId,1,3); Geocomp=substr(geographyId,4,2); if geocomp='00' then AreaName=Name; else do; Areaname=scan(Name,1,';'); Geocomp_name=scan(Name,2,';'); end; select(sumlev); when('010') geocode=' '; when('020') do; Region=_gcode; Areaname=trim(areaname)||' Region'; end; when('030') do; Division=_gcode; Areaname=trim(areaname)||' Division'; end; when('040') do; State=_gcode; end; when('050') do; County=_gcode; State=substr(_gcode,1,2); end; when('060') do; County=_gcode; State=substr(_gcode,1,2); cousubfp=substr(_gcode,6,5); end; when('160') do; State=substr(_gcode,1,2); placefp=substr(_gcode,3,5); end; when('250') do; OTSA=_gcode; end; when('310') do; cbsa=_gcode; if index(areaname,'Micropolitan') then cbsatype='micro'; else cbsatype='metro'; end; when('312') do; cbsa=substr(_gcode,1,5); placefp=substr(_gcode,8,5); State=substr(_gcode,6,2); end; when('314') do; cbsa=substr(_gcode,1,5); MetroDiv=substr(_gcode,6,5); end; when('330') do; CSA=_gcode; end; when('335') do; *--combined necta---; end; when('350') do; NECTA=_gcode; end; when('352') do; NECTA=substr(_gcode,1,5); State=substr(_gcode,6,2); placefp=substr(_gcode,8,5); end; when('355') do; NECTA=substr(_gcode,1,5); end; when('400') do; ua=_gcode; end; when('500') do; State=substr(_gcode,1,2); congdist=substr(_gcode,3,2); end; when('795') do; state=substr(_gcode,1,2); puma5=substr(_gcode,3,5); end; when('950','960','970') do; state=substr(_gcode,1,2); School=substr(_gcode,3,5); end; end; if State ne ' ' then do; Stab=put(state,$fipstab.); length _divr $2; *--we use a format code to "look up" the division and regions codes for the state--; _divr=put(state,$stdivr.); Division=substr(_divr,1,1); Region=substr(_divr,2,1); end; if sumlev ne lag(sumlev) then put / sumlev= $sumlev. / _all_; drop _: ; rename GeographyId=geoid; *<-------------------------Note----------------------------; run; proc contents data=acs.geography; run; proc datasets library=acs; modify geography; index create geoid; quit; proc freq data=acs.geography; table sumlev state geocomp_name geocomp; format state $fipstab. sumlev $sumlev30.; run;