x cd /pub/data/popests/Tools; %let pgm=aggpopests_moregns; filename pgm "&pgm..sas"; /*----------------------------------------------------------------------------------------------------------------- This code aggregates popests county data to various Missouri regions. We keep them in single dataset with our own SumLev codes to allow selection: rpc - Regional Planning Commissions ded - Dept of Economic Development regions dot - Dept of Transportaion districts uoe - UM Outreach and Extension regions. aaa - Area agency on aging districts. uic - Urban Influence codes. Not contiguous regions but interesting summaries. mty - Metro type (CBSA type actually): 3-tiered Met(ro) Mic(ro) and Not (in a CBSA). 311 - CBSA within State. Coded by John Blodgett, OSEDA, U. of Missouri, blodgettj@umsystem.edu Under contract with the Missouri Census Data Center Revision History: 03.23.06 Coding begins. 03/22/07: Running with vintage 06 estimates. 03/31/07: Running again after fix to cbsa code for Clark county. 03/13/08: Editing to run with 2007 data (but not run yet). (Running with new data 3/20/08) Rerun with corrected 2007 data, 3-25-08. 03/19/09: Editing to run with 2008 data 03/23/10: Editing to run with 2009 data 04/12/12: Editing to run with 2011 data (new decade) 03/14/13: Editing to run with 2012 data 03/27/14: Editing to run with 2013 data 03/26/15: Editing to run with 2014 data 03/24/16: Editing to run with 2015 data 03/23/17: Editing to run with 2016 data ------------------------------------------------------------------------------------------------------*/ options ls=132 ps=80 ; %let baseyear=2010; %let baseyr=%substr(&baseyear,3,2); %let yr=16; *---we aggregate the estimates data in popests.mocom&yr to create popests.mocomregns&yr --; libname popests '/pub/data/popests'; libname georef '/pub/data/georef' access=readonly; title "&pgm : Aggregate Missouri County Level Data to County-Based Regions Types"; data aggin; length sumlev $3 region $5; merge georef.mocogeos(keep=county ded_region rpc umx2 dot aaa ui_code cbsa cbsatype in=ingeos) popests.mocom&yr(in=in where=(sumlev='050')); by county; if not (ingeos and in) then do; put //'*******************PROBLEM!!!!!!!!!!!!!!!!!!!!!!: Data Missing on One of the files!!!!! '/ county= ingeos= in=; 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; sumlev='aaa'; region=aaa; output; sumlev='uic'; region=ui_code; output; sumlev='311'; region=cbsa; output; sumlev='mty'; region=cbsatype; if region=' ' then region='Not'; output; *--values will be Met, Mic and Not--; drop rank: rbirth: rdeath: rnetmig: ; run; proc sort; by sumlev region; run; %agg(setin=aggin, setout=aggout, aggby=sumlev region, agglvl=1, means=PctChang PctCh1yr, mweights=Pop&baseyr.C poplastyr, aggvars=_numeric_, debug=0) ; run; data popests.mocomregns&yr(label="Mo pop ests w components of change &baseyear.-20&yr agg to regions"); length SumLev $3 Geocode $5 AreaName $64 dot ded_region rpc umx2 aaa ui_code cbsatype $3 cbsa $5; set aggout; by sumlev; geocode=region; ; drop 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; when('uic') do; ui_code=geocode; areaname=put(ui_code,$ui_code.); end; when('311') do; CBSA=geocode; areaname=put(cbsa,$cbsa.); end; when('mty') do; cbsatype=geocode; if cbsatype='Met' then areaname='Metropolitan Statistical Areas'; else if cbsatype='Mic' then areaname='Micropolitan Statistical Areas'; else areaname='Outsides Metro or Micropolitan Areas'; end; end; *--select stmt--; format pct: 5.1; drop _lvl_; rename _nag_=ncos; label _nag_='# counties'; label ui_code='Urban Influence Code (ERS)' dot='MoDOT District' rpc='Region Planning Council' aaa='Area Agency on Aging' umx2='UM Extension Region' ded_region='Economic development region (DED)'; run; proc contents data=popests.mocomregns&yr position; run cancel; ods html file="../Reports/popests_moregns.html" style=sasweb; *---Run a test step to see if everything sums up to state total pop---; proc print label data=popests.mocomregns&yr; by sumlev; format sumlev $sumlev.; label sumlev='Geographic Units'; title "Population Estimates With Components of Change &baseyear.-20&yr"; title2 "Aggregated from County Data to Assorted Regions for Missouri"; footnote .h=1 "Produced by setup in popests/Tools/aggpopests_moregns.sas from Data in popests.mocomregns&yr"; by sumlev; id geocode areaname; var ncos popest popchang pctChang NetMig NatrlInc; **sum ncos popest popchang; run; ods html close;