x cd /pub/data/stf901/Tools; %let pgm=moregns00; filename pgm "&pgm..sas"; /*----------------------------------------------------------------------------------------------------------------- This code aggregates stf901 data to various Missouri regions as defined in 2000. 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: 3.25.02: Coding begins. ------------------------------------------------------------------------------------------------------*/ libname stf901 '/pub/data/stf901'; libname user '/SAS_temp/user'; *<===Optional. Permissions on this directory limit who can use it; libname georef '/pub/data/georef'; title 'stf901 Aggregation Run: To Missouri Regions: rpcs, ded, dot and uoe'; options msglevel=i; /*<=========================Comment out===================================== ===========================End commented out================================ */ data aggin(compress=yes); length sumlev $3 region $3; merge georef.mocogeos(keep=county ded_region rpc umx2 dot pop2k rename=(pop2k=pop2000) in=ingeos) stf901.moi(where=(slvl='050') keep=county slvl _numeric_ in=insf1); by county; if not (ingeos and insf1) then do; put //'*******************PROBLEM!!!!!!!!!!!!!!!!!!!!!!: Data Missing on One of the files!!!!! '/ county= ingeos= insf1=; 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 data=aggin; by sumlev region; run; %agg(aggin=aggin,aggout=aggout, aggby=sumlev region, aggvars=pop2000 intptlat intptlng AreaSqmi p1i1--h55i4, MEANS=intptlat intptlng P17AI1 H17AI1 H18AI1 H18AI2, MWEIGHTS=p1i1 p1i1 P2I1 H2I1 H3I1 H3I2 , debug=1, agglvls=1) run; data stf901.moregns00(label='MO County-based Regions as of 2000' sortedby=SumLev Region) ; length sumlev $3 geocode region ded_Region $3 dot rpc umx2 $2 areaname $40 state $2; retain state '29'; set aggout; geocode=region; select (sumlev); when('ded') do; ded_region=region; areaname=put(ded_region,$dedrgn.); end; when('dot') do; dot=region; areaname=put(dot,$modot.); end; when('rpc') do; rpc=region; areaname=put(rpc,$rpcname.); end; when('umx') do; umx2=region; areaname=umx2||' MU Extension Region'; end; otherwise do; put sumlev= ' *****unexpectd sumlev code ----aborting step!!!!!!!!!!!!! ********************** '; abort abend; end; end; *--select--*; drop _lvl_ _nag_ ; label ded_Region='Dept of Economic Development region' dot='MO Dept of Transp. District' rpc='Regional Planning Commission' umx2='MU Extension Region'; format intptlng 11.6 intptlat 10.6; rename intptlng=IntPtLon; *<---------naming convention inconsistent across decades. We rename to go with the 2000 name; *---code taken from the sascode(aggstf1.sas) module. Estimate percentiles using median macro--; RETAIN HV1 15000 HV2 HV3 HV4 HV5 HV6 HV7 HV8 5000 HV9 10000 HV10 15000 HV11 HV12 HV13 HV14 HV15 25000 HV16 HV17 50000 HV18 HV19 50000 HV20 200000 R1 100 R2-R14 50 R15 250 R16 500; ARRAY HVALUE HV1-HV20; *<--MEASURES OF THE "WIDTHS" OF H23 CELLS; ARRAY RENTS R1-R16; *<--MEASURES OF THE "WIDTHS" OF H32 CELLS; ARRAY NVALUE H23I1-H23I20; ARRAY NRENTS H32I1-H32I16; %MEDIAN(INTSIZE=HVALUE,INTVALS=NVALUE,Q1=H23AI1,MDN=H23BI1,Q3=H23CI1) %MEDIAN(INTSIZE=RENTS,INTVALS=NRENTS,Q1=H32AI1,MDN=H32BI1,Q3=H32CI1, SAMESTEP=1) *--ROUND ALL VALUES TO NEAREST DOLLAR--*; H23AI1=ROUND(H23AI1); H23BI1=ROUND(H23BI1); H23CI1=ROUND(H23CI1); H32AI1=ROUND(H32AI1); H32BI1=ROUND(H32BI1); H32CI1=ROUND(H32CI1); P17AI1=ROUND(P17AI1,.01); H17AI1=ROUND(H17AI1,.01); H18AI1=ROUND(H18AI1,.01); H18AI2=ROUND(H18AI2,.01); drop hv1-hv20 r1-r16; drop _haf -- _slot2; *--temp vars used by median macro--; run; *---verify that the total pops agg to state total---; proc means data=stf901.moregns00(keep=sumlev pop2000) sum n min max mean; class sumlev; var pop2000; title2 'Means of stf901.moregns00, by SumLev'; run;