x cd /pub/data/acspums/Tools; %let pgm=acs20123yr; filename pgm "&pgm..sas"; *---Access 3yr ACS PUMS sas datasets for the 2010-2012 period for Mo only and entire US. As downloaded from AFF site, 02-06-14 & 02-12-14, jgb ****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=2012; %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!---*; 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'; 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. See the Readme file in the acspums data directory for more info re the PUMA situation.---; if puma10 ne '-0009' then puma=puma10; else do; length _arg $7; _arg=st||puma00; drop _arg; puma=put(_arg,$pma2k12_.); *<---starting in 2012 vintage we assign 2010 PUMA if it can be implied from puma00-; end; 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!---*; set dwnlds.psam_p&sfx; length Year $4 puma $5; Year=substr(serialno,1,4); State=st; if puma10 ne '-0009' then puma=puma10; else do; length _arg $7; _arg=st||puma00; drop _arg; puma=put(_arg,$pma2k12_.); *<---starting in 2012 vintage we assign 2010 PUMA if it can be implied from puma00-; end; ***if puma00='00600' then put / _all_; run; proc tabulate data=acspums.&stab.precs&yr.3yrα class puma; by st; format st $state.; var pwgtp; table (all puma), pwgtp*sum*f=comma13.; title "Summing Weight Variables on acspums.&stab.precs&yr.3yr&alpha"; run; %mend doit; %*doit(29,mo); *--Decided to make these views instead of regulat data sets. See proc sql step, below--; %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;