x cd /pub/data/sf32000/Tools; %let pgm=aggsf3_moregns; filename pgm "&pgm..sas"; /*----------------------------------------------------------------------------------------------------------------- This code aggregates sf32000 county data to various Missouri regions. We keep them in single datasets rather than going to ph, phct and phctr subsets. rpc - Regional Planning Commissions ded - Dept of Economic Development regions dot - Dept of Transportaion districts uoe - UM Outreach and Extension regions. Coded by John Blodgett, OSEDA, U. of Missouri, blodgettj@umsystem.edu Under contract with the Missouri Census Data Center Revision History: 12.12.02: Coding begins. ------------------------------------------------------------------------------------------------------*/ libname sf32000 '/pub/data/sf32000'; libname sf3 (sf32000); *<--alternate name--; %libname(georef); libname user '/tmp/scratch/user'; title "&pgm : Aggregate Missouri County Level Data to 4 County-Based Regions Types"; options msglevel=i; title "&pgm: Aggregate 2000 sf3 Datasets to Various Missouri County-Based Regions (rpc, ded, dot, uoe)"; data agginsf3(compress=yes); length sumlev $3 region $3; merge georef.mocogeos(keep=county ded_region rpc umx2 dot in=ingeos) sf3.mostcnty(in=insf3 where=(sumlev='050')); by county; if not (ingeos and insf3) then do; put //'*******************PROBLEM!!!!!!!!!!!!!!!!!!!!!!: Data Missing on One of the files!!!!! '/ county= ingeos= insf3=; abort abend; end; *---Output once for each region type--; keep sumlev region _numeric_; sumlev='ded'; region=ded_region; output; sumlev='dot'; region=dot; output; sumlev='umx'; region=umx2; output; sumlev='rpc'; region=rpc; output; run; proc sort; by sumlev region; run; %macro postx; *--this code executed at post step; geocode=region; ; select (sumlev); when('dot') do; dot=geocode; areaname=put(region,$modot.); end; when('ded') do; ded_region=geocode; areaname=put(region,$dedrgn.); end; when('rpc') do; rpc=geocode; areaname=put(region,$rpcname.); end; when('umx') do; umx2=geocode; areaname=put(region,$umxname.); end; end; *--select stmt--; %mend postx; *<=============Note the macro is aggsf3A -- the A is for Alternate version. This one does NOT assume you have broken the sf3 data into 3 separate sets. ======================*; options mprint; %aggsf3a(setin=agginsf3, setout=sf32000.moregns, aggby=sumlev region, idlens=%str(SumLev $3 geocode region ded_region $3 dot rpc umx2 $2 Areaname $40), agglvl=1, steps=agg post, afact=, postexit=postx) run; *----------------------------------(3 of 3): Aggregate the phctr dataset--------------------------------------------*; *---Run a test step to see if everything sums up to state total pop---; proc print data=sf32000.moregns(keep=_char_ pop100 hu100 p1i1 h1i1 pct1i1 ); by sumlev; id geocode; var region areaname dot rpc umx2 ded_region _numeric_; sum _numeric_; run; %include sascode(notify);