x cd /home/riceg/ACS_SAS_processing; %let pgm=process_mcdcprofiles1yr; filename pgm "&pgm..sas"; /* Process the std usmcdprofiles 1yr data set to add geocodes and change sort order. */ %let year=2017; %let yr=%substr(&year,3,2); title "&pgm.: Convert &year 1yr Geographic headers Data"; %include '/pub/sas/autoexec.sas'; options compress=binary; libname user '/home/riceg/ACS_SAS_processing/temp'; libname acs&year "/pub/data/acs&year"; libname acs (acs&year); proc sort data=acs.usmcdcprofiles out=user.usmcdcprofiles; by state geoid; run; *-- The state and county variables come in as numerics. So we have to change that. ; data user.usmcdcprofilesEdited; length State $2 County $5; set user.usmcdcprofiles (rename=(state=_nstate county=_ncounty)); if _nstate > 0 then State=put(_nstate,z2.); if _ncounty > 0 then County=put(_ncounty,z5.); run; *data user.usmcdcprofiles(label="US std profiles for &year 1-yr estimates" index=(state)); *-- TEST ; data acs.usmcdcprofiles(label="US std profiles for &year 1-yr estimates" index=(state)); merge acs.allgeos1.yr (in=ingeos) user.usmcdcprofilesEdited (in=indata rename=(areaname=_areanameck)); by state geoid; DateCreated=today(); format DateCreated date.; _ix=index(areaname,'0D'x); *-- These characters somehow were appended to the areanames. ; if _ix then substr(areaname,_ix)=' '; if not (indata and ingeos) then do; _nbad+1; if _nbad le 10 then put / _all_; else abort abend; delete; end; if geocomp='00' and (not (areaname=: _areanameck)) then do; *-- We have some (outdated) PUMA names for Misssouri that we now have to replace the official names. ; if geoid=:'79500US29' then ; else put /'**areanames do not match: ' state= geoid= areaname= _areanameck=; end; format pct: 5.1; *-- Some of the percentage variables did not have formats associated with them. (Some did.) ; drop sldu sldl zcta5 puma1 bg submcd macc aits ; *-- These vars not used in 1yr data. ; drop _: set ; *-- "set" variable is a bug that we need to fix ; run; options ls=160; proc print data=user.usmcdcprofiles(keep=_character_ totpop obs=100); where geocomp='00'; by state; id geoid; run; %include sascode(notify);