x cd /pub/data/acspums/Tools; %let pgm=acs20133yr; filename pgm "&pgm..sas"; *---Access 3yr ACS PUMS sas datasets for the 2011-2013 period for Mo only (and entire US?). As downloaded from AFF site, March, 2015. Running in late May, 2015. ( We earlier created a BAD mo 3yr dataset that was really just a repeat of the 1yr.) ****the psam_* datasets referenced here will be deleted after this runs. They can be put back by using unzip on the unix_*.zip files which were downloaded from http://www2.census.gov/acs2012_3yr/pums/ ---*; libname acspums '/pub/data/acspums'; libname dwnlds '/pub/data/acspums/downloads'; %let year=2013; *<================================================; %let yr=%substr(&year,3,2); options compress=char; %macro doit(state,stab,alpha); %*let upstab=%upcase(&stab); %if &alpha=a %then %let states=AL thru HI; %else %if &alpha=b %then %let states=ID thru MS; %else %if &alpha=c %then %let states=MO thru OR; %else %if &alpha=d %then %let states=PA thru WY; %else %let states=%upcase(&stab); %local sfx; %if &state=00 %then %let sfx=usα %else %let sfx=&state; data acspums.&stab.hrecs&yr.3yr&alpha(label="&states H recs data for 3-year period ending 20&yr" index=(state)); length State ST $2; *---ST was $3 on input!---*; length Year $4 PUMA10alt $5; *---Alternate 2010 PUMA with imputed vals in 37.5 pct of cases using the 2000 PUMA as table lookup-; label Year='Year surveyed'; set dwnlds.psam_h&sfx; ***length Year $4 puma $5; Year=substr(serialno,1,4); State=st; label puma00='PUMA 2k code' puma10='PUMA 2010 code'; if puma00=' ' then do; put '***Not a multi-year input data set: puma00 not defined ***'; abort abend; end; ***label puma='PUMA code starting in 2012 (may be assigned based on PUMA00 in prior years)'; *----We created a format table where we can look up 2k PUMA codes to see if they can be mapped to a 2010/2012 PUMA code. In some states (e.g. VT and DE) this works really well, but in other, fast-growing states it does not help much. PUMA_imputation.txt file for explanation---; if puma10 = '-0009' then do; length _arg $7; _arg=st||puma00; drop _arg; puma10alt=put(_arg,$pma2k12_.); *<---starting in 2012 vintage we assign 2010 PUMA if it can be implied from puma00-; end; else puma10alt=puma10; run; data acspums.&stab.precs&yr.3yr&alpha(label="&states P recs data for 3-year period ending 20&yr" index=(state)); length State ST $2; *---ST was $3 on input!---*; length Year $4 PUMA10alt $5; *---We can impute the 2010 PUMA in 37.5 pct of cases using the 2000 PUMA as table lookup-; label Year='Year surveyed'; set dwnlds.psam_p&sfx; if puma00=' ' then do; put '***Not a multi-year input data set: puma00 not defined ***'; abort abend; end; Year=substr(serialno,1,4); State=st; label puma00='PUMA 2k code' puma10='PUMA 2010 code'; if puma10 = '-0009' then do; length _arg $7; _arg=st||puma00; drop _arg; puma10alt=put(_arg,$pma2k12_.); *<---starting in 2012 vintage we assign 2010 PUMA if it can be implied from puma00-; end; else puma10alt=puma10; ***if puma00='00600' then put / _all_; run; proc tabulate data=acspums.&stab.precs&yr.3yrα class puma00 puma10 puma10alt year; by st; format st $state.; var pwgtp; table year* (all puma00 puma10 puma10alt)* pwgtp*sum*f=comma13.); title "Summing Weight Variables on acspums.&stab.precs&yr.3yr&alpha"; run; %mend doit; options mprint; %doit(29,mo); *--Might decide to make these views instead of regulat data sets. See proc sql step, below--; /*<=========================Comment out===================================== %doit(00,us,a); %doit(00,us,b); %doit(00,us,c); %doit(00,us,d); proc sql; *----Create MO views----*; create view acspums.mohrecs123yr as select * from acspums.ushrecs123yrc where state='29'; create view acspums.moprecs123yr as select * from acspums.usprecs123yrc where state='29'; quit; ===========================End commented out================================ */