x cd /pub/data/stf903/Tools; %let pgm=aggstf903_moregns; filename pgm "&pgm..sas"; /*----------------------------------------------------------------------------------------------------------------- This code aggregates stf903 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.14.02: Coding begins. Modeled after aggsf3_moregns for sf32000. 02.08.06: Running again to create new moregns06 which contains data for regions as defined in 2006. The only change will be to the RPCs (06 and 08 had changes). We also are now adding AAA regions - Area Agencies on Aging. ------------------------------------------------------------------------------------------------------*/ libname stf903 '/pub/data/stf903'; libname georef '/pub/data/georef' access=readonly; libname user '/SAS_temp/user'; options msglevel=i; title "&pgm: Aggregate 1900 sf3 Datasets to Various Missouri County-Based Regions (rpc, ded, dot, uoe)"; data agginsf3(compress=yes); length sumlev $3 geocode region $3 AreaName $42; *<----the georef.mocogeos dataset has been modified to reflect values as of Jan, 2006---; merge georef.mocogeos(keep=county ded_region rpc umx2 dot aaa in=ingeos) stf903.mostcnty(in=insf3 where=(sumlev='050') drop=rpc); *--rpc was on the dataset. Just to make sure it has not changed since 90 we drop the old value--; 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--; length Geocode $3; keep sumlev region geocode State areaname _numeric_; sumlev='ded'; region=ded_region; output; sumlev='dot'; region=dot; output; sumlev='umx'; region=umx2; output; sumlev='rpc'; region=rpc; output; sumlev='aaa'; region=aaa; output; run; proc sort; by sumlev region; run; *<=============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. ======================*; *----We use the module in sascode(agg903.sas) to do the aggregation, but we have to assing the global parms used by that module so it knows where things come from and go to. ----*; %let _aggin=agginsf3; %*let _aggout=stf903.moregns; *---we ran this back in 2003--; %let _aggout=stf903.moregns06; *---running with new geography defns 2/06---; %let _aggby=sumlev region; %let skipagg=0; %let _grand=0; %let _agglvl=1; %let _idvars=State areaname; %let _facvar=; %include '/pub/sascode/agg903.sas'/source2; *<---include standard sas code to do the actual aggregation based on all the global parms just assigned. Includes a post step to handle medians----; slvl=SumLev; 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; when('aaa') do; aaa=geocode; areaname=put(region,$aaa.); end; end; *--select stmt--; run; *---Run a test step to see if everything sums up to state total pop---; proc print data=&_aggout(keep=_char_ p1i1 h1i1 ); title2 "Sample Data form &_aggout"; by sumlev; id geocode; var region areaname dot rpc umx2 ded_region _numeric_; sum _numeric_; run;