x cd /pub/data/sf32000/Tools; %let pgm=agg_uspumas; filename pgm "&pgm..sas"; *---3-2-09 (do-over): Allocate split BG data to 5% PUMAs for entire US.---; *----6-23-09: Rerunning to add Logrecno variable with value = obs #. This is for consistency with sf32000x.uspumas which has such a value and which is used as a key by the sf3tabgen websas pgm. ----; %include '/pub/sascode/mcdc3.sas'; ***libname xxsl090 server=mcdc3.mcdcshr3; **this libname is defined in the above included module--; libname sf32000 '/pub/data/sf32000'; libname temp '/pub/data/sf32000/temp'; %libname (corrlst); %let statenm=Delaware; %let bgkeys=county cousubfp placefp tract urbanrur bg; %Macro preexit; %mend; %Macro postexit; SumLev='795'; if state='29' then areaname=put(puma5,$mopuma.); else areaname="&statenm PUMA "||puma5; geocode=state||puma5; drop afact; %mend postexit; %macro doit(state,stab); /*proc means data=xxsl090.&stab.ph(keep=county pop100) sum; class county; var pop100; run; proc means data=corrlst.sbg2k_puma_&stab(keep=county pop2k) sum ; class county; var pop2k; run; */ data agginph; merge xxsl090.&stab.ph(in=insf3 where=(pop100)) corrlst.sbg2k_puma_&stab(in=inclist where=(pop2k)); by &bgkeys ; if not (insf3 and inclist) then do; _nbad+1; if _nbad le 20 then put insf3= inclist= pop2k= pop100= afact= +1 &bgkeys; if _nbad ge 100 then abort abend; if insf3; end; *--Calculate 2 new universe variables needed for aggregating. These are the 100 pct counts for occupied and vacant hus-; if H4i1 then H3i2=100*(H2i2/H4i1); *--100% count of occ units is occ units sampled divided by pct occ units sampled-; if H4i2 then H3i3=100*(H2i3/H4i2); *--100% count of vac units is vac units sampled divided by pct vac units sampled-; label H3i2='100% Count of Occupied hus (derived)' H3i3='100% Count of Vacant units (derived)'; drop PCT; *--this was a little flag var we set which is irrelevant after aggregation-; keep SumLev State county puma5 areaname _numeric_; run; proc datasets library=work; modify agginph; index create puma5; quit; proc means data=agginph sum ; class state county; var pop100; run cancel; *<---just a test for early run to make sure...--; options nomprint; %aggsf3( settypes=ph, steps=agg post, setinlib=work, setin=aggin&stab, setoutlib=temp, setout=&stab.pumas, aggby=puma5, idlens=SumLev $3 geocode $7 AreaName $64, idvs=state, afact=afact, compress=no, report=0); %mend doit; options mprint; %*doit(10,de) ; %*dostates(n=51,names=1,msgs=1) ; %macro doit(state,stab); temp.&stab.pumasph %mend doit; *---concatenate the 51 state datasets to create the uspumasph data set---; data sf32000.uspumasph(label='P & H table data for all 5% PUMA areas in U.S.' index=(state)); retain Logrecno 0; set %dostates(n=51) open=defer ; LogRecNo+1; run; proc datasets library=sf32000 nolist; index create logrecno; quit; %include sascode(notify);