x cd /pub/data/sf12010/Tools; %let pgm=application_agesexrace_extregion; filename pgm "&pgm..sas"; *---For Paula Hudson, MU Extension Tech Comp Svcs. Some basic dempographics by 3 age, basic race and hispanic cats and gender summaries for Mo counties by UM Ext Regions. jgb, 1-12. ---*; libname sf12010 '/pub/data/sf12010' access=readonly; libname georef '/pub/data/georef' access=readonly; libname user '/SAS_temp/user'; libname temp '/pub/data/temp'; /* ========================begin comment==================================== *---Pull relevant pct12 tables----; data pct12; set sf12010.moinventory(where=(sumlev='050') keep=_character_ pct12i: p1i1); run; data pct12x; set sf12010.mophctr(where=(sumlev='050') keep=_character_ pct12ai1--pct12hi209); run; ==========================end comment====================================== */ data temp.mocounty_demographics2010(label='Custom extract for Paula Hudson, UM Ext'); merge pct12(in=in1) pct12x(in=in2) georef.mocogeos(in=in3 keep=fipco county areaname umx2) ; length fipco $5 CntyName $16 ExtRegion $16 PopGroup $24; by county; if not (in1 and in2 and in3) then do; _bad+1; if _bad le 5 then put // _all_; else abort abend; end; **TotalPop= p1i1; CntyName=areaname; ExtRegion=put(umx2,$umxname.); %macro dopct12(sfx,popgroup); PopGroup="&popgroup"; Total=pct12&sfx.i1; Under5= sum(of pct12&sfx.I3-pct12&sfx.I7 pct12&sfx.I107-pct12&sfx.I111); Age5_17= sum(of pct12&sfx.I8-pct12&sfx.I20 pct12&sfx.I112-pct12&sfx.I124); Over18= Total - Under5 - Age5_17; MaleTot=pct12&sfx.i2; MaleUnder5= sum(of pct12&sfx.I3-pct12&sfx.I7 ); MaleAge5_17= sum(of pct12&sfx.I8-pct12&sfx.I20); MaleOver18= MaleTot - MaleUnder5 - MaleAge5_17; FemaleTot=pct12&sfx.i106; FemaleUnder5= sum(of pct12&sfx.I107-pct12&sfx.I111); FemaleAge5_17= sum(of pct12&sfx.I112-pct12&sfx.I124); FemaleOver18= FemaleTot - FemaleUnder5 - FemaleAge5_17; output; %mend dopct12; %dopct12(,Total) %dopct12(a,White Alone) %dopct12(b,Black Alone) %dopct12(c,Am Indian Alone) %dopct12(d,Asian Alone) %dopct12(e,Hawaiian & Other PI alone) %dopct12(g,Multi Race) %dopct12(h,Hispanic) keep fipco cntyname umx2 extregion PopGroup Total Under5--FemaleOver18; run; proc sort; by extregion fipco; run; proc print data=temp.mocounty_demographics2010(obs=40); by extregion umx2; id fipco cntyname popgroup; run;