x cd /pub/data/sf32000/Tools; %let pgm=agg_moregns; filename pgm "&pgm..sas"; *---5-19-09: Aggregate to various Mo county-based regions (rpcs, modot, umx, etc.---; ***libname xxsl090 server=mcdc3.mcdcshr3; **this libname is defined in the above included module--; libname sf32000 '/pub/data/sf32000'; libname sf3 (sf32000); %libname(georef); libname user '/tmp/scratch/user'; %macro addgeos(set); data aggin&set; length geocode $8; merge sf3.mo&set(where=(sumlev='050' and geocomp='00') in=indata) georef.mocogeos(keep=state county rpc umx umx2 dot ded_region cbsa aaa Sumlev in=ingeos); by county; if indata and ingeos; if cbsa=' ' then cbsa='99999'; sumlev='311'; geocode=cbsa||'-'||state; output; sumlev='aaa'; geocode=aaa; output; sumlev='ded'; geocode=ded_region; output; sumlev='dot'; geocode=dot; output; sumlev='rpc'; geocode=rpc; output; sumlev='umx'; geocode=umx2; output; drop county geocomp; run; proc sort; by sumlev geocode; run; %mend addgeos; %addgeos(ph) %addgeos(phct) %addgeos(phctr) %Macro preexit; %mend; %Macro postexit; select (sumlev); when('311') Areaname=trim(put(cbsa,$cbsa.)); when('aaa') Areaname=put(aaa,$aaa.); when('ded') Areaname=put(ded_region,$dedrgn.); when('dot') Areaname=put(dot,$modot.); when('rpc') Areaname=put(rpc,$rpcname.); when('umx') Areaname=put(umx,$umxname.); otherwise do; put '****Otherwise clause reached -- logic error ****' sumlev= ; abort abend; end; end; if sumlev ne '311' then cbsa=' '; if sumlev ne 'aaa' then aaa=' '; if sumlev ne 'ded' then ded_region=' '; if sumlev ne 'dot' then dot=' '; if sumlev ne 'rpc' then rpc=' '; if sumlev ne 'umx' then do; umx=' '; umx2=' '; end; %mend postexit; %aggsf3(settypes=ph phct phctr,setinlib=user, setin=aggin,setoutlib=sf3,setout=moregns06, aggby=sumlev geocode,idvs=umx umx2 cbsa aaa ded_region dot rpc state, idlens=%str(SumLev $3 geocode $8 AreaName $64), templib=user, report=0) data sf3.moregns06(compress=yes label='Mo county-based regions as defined circa 2006' index=(sumlev)); merge sf3.moregns06ph sf3.moregns06phct sf3.moregns06phctr; by sumlev geocode; run; proc freq data=sf3.moregns06; table sumlev cbsa aaa ded_region dot rpc; table umx2*umx/list; run; %include sascode(notify);