x cd /pub/data/acs2014/Tools; %let pgm=process_mcdcprofiles1yr; filename pgm "&pgm..sas"; *---Process the std usmcdprofiles 1yr data set created by Glenn R. to add geocodes and change sort order. jgb, starting 9-17-15 ---*; %let year=2014; %let yr=%substr(&year,3,2); %let period=1; *--can be 1, 3 or 5---; %let yearm4=%eval(&year-4); title "&pgm.: Convert &year &period Geographic headers Data"; options compress=NO; **libname user '/SAS_temp/userb'; libname acs&year "/pub/data/acs&year"; *<====; libname acs (acs&year); *--assign alias---; *<====we manually renamed original data set here, adding the _2014 suffix. ===============; proc sort data=acs.usmcdcprofiles_&year out=usmcdcprofiles_&year; by state geoid; run; *---somehow the state and county variables came in as numerics. So we have to change that--; data usmcdcprofilesEdited; length State $2 County $5; set usmcdcprofiles_&year (rename=(state=_nstate county=_ncounty)); if _nstate > 0 then State=put(_nstate,z2.); if _ncounty > 0 then County=put(_ncounty,z5.); data acs.usmcdcprofiles(label="US std profiles for &year &period.-yr estimates" index=(state)); merge acs.allgeos&period.yr (in=ingeos) 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=acs.usmcdcprofiles(keep=_character_ totpop obs=100); where geocomp='00'; by state; id geoid; run;