x cd /pub/data/sf32000/Tools; %let pgm=agg_mopumasphct; filename pgm "&pgm..sas"; *---allocate phct and phctr tables to estimate data for Mo PUMAs. We use tract level data as source. Creates datasets sf32000.mopumapchct and sf32000.mopumasphctr . We only have phct and phctr data at tract level for Missouri (as of 2/10). ----; libname sf32000 '/pub/data/sf32000'; %libname (corrlst); %let statenm=Missouri; %let trkeys=county tract; %Macro preexit; **MUST be defined even if it does not do anything! *********; %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 sql; *<---this view is the tract level data sorted by county and tract----; create view &stab.tractsphct as select * from sf32000.&stab.phct where pop100>0 and sumlev='140' order by county, tract; create view &stab.tractsphctr as select * from sf32000.&stab.phctr where pop100>0 and sumlev='140' order by county, tract; quit; data agginphct; merge &stab.tractsphct (in=insf3) corrlst.&stab.tr2puma2k(in=inclist where=(pop2k)); by &trkeys ; if not (insf3 and inclist) then do; _nbad+1; if _nbad le 20 then put insf3= inclist= pop2k= pop100= afact= +1 &trkeys; if _nbad ge 100 then abort abend; if insf3; end; keep SumLev State county puma5 areaname _numeric_; run; proc datasets library=work; modify agginphct; index create puma5; quit; data agginphctr; merge &stab.tractsphctr (in=insf3) corrlst.&stab.tr2puma2k(in=inclist where=(pop2k)); by &trkeys ; if not (insf3 and inclist) then do; _nbad+1; if _nbad le 20 then put insf3= inclist= pop2k= pop100= afact= +1 &trkeys; if _nbad ge 100 then abort abend; if insf3; end; keep SumLev State county puma5 areaname _numeric_; run; proc datasets library=work; modify agginphctr; index create puma5; quit; proc means data=agginphct sum ; class state county; var pop100; run ; *<---just a test for early run to make sure...--; options nomprint; %aggsf3( settypes=phct phctr, steps=agg post, setinlib=, setin=, setoutlib=sf32000, setout=&stab.pumas, aggby=puma5, idlens=SumLev $3 geocode $7 AreaName $64, idvs=state, afact=afact, compress=yes, report=0); %mend doit; options mprint; %doit(29,mo) ; %*dostates(n=51,names=1,msgs=1) ;