x cd /pub/data/acs/Tools; %let pgm=appEducationByAge; filename pgm "&pgm..sas"; *---Extract data from the 2012 vintage Missouri places data set. We want the count of persons aged 45+ with at least a high school diploma. Merge this data with median HH income data. Per request from user L Salerno 10/14. See setup appEducationByAgeMoHouse where we run this with Mo House Districts data downloaded via AFF , 11/12/14. ---*; libname user '/SAS_temp/user'; libname btabs5 '/pub/data/acs2012/btabs5yr'; %libname(acs2012); libname temp '/pub/data2/temp' ; *----Step 1: Pull counts of "educated seniors". Not exactly, of course.---; data educ; set btabs5.moplaces09_16(keep=sumlev county esriid areaname b15001i: where=(sumlev='155' and (b15001i1 >= 1500))); Over45HSgrad=sum(of b15001i30-b15001i34 b15001i38-b15001i42 b15001i71-b15001i75 b15001i79-b15001i83); *---These next 2 we begin by calculating exactly the level, but then below we add things to make them "...or more" measures---; Over45Somec=sum(of b15001i31 b15001i39 b15001i72 b15001i80); Over45Bdegree=sum(of b15001i32 b15001i40 b15001i73 b15001i81 b15001i33 b15001i41 b15001i74 b15001i82); Over45Gradpro=sum(of b15001i34 b15001i42 b15001i75 b15001i83); label Over45somec='Some College or more (over 45)' Over45bdegree='Bachlrs degree or more (over 45)'; *--make them all cumulative (...or more) measures--; Over45bdegree+Over45gradpro; Over45somec+Over45bdegree; Over45=sum(of b15001i27 b15001i35 b15001i68 b15001i76); if Over45HSgrad >= 500 ; PctOver45HSgrad=100*Over45HSgrad/Over45; PctOver45Somec=100*Over45Somec/Over45; PctOver45Bdegree=100*Over45Bdegree/Over45; PctOver45Gradpro=100*Over45GradPro/Over45; *if pctover45hsgrad >= 25; drop b15:; format pct: 5.1; run; proc sort; by esriid; run; data _null_; set acs2012.usstcnty5yr(keep=sumlev state medianhhinc); where sumlev='040' and state='29'; call symput ('statemedian',put(medianHHInc,6.)); stop; run; %put Statemedian=&statemedian; data income; set acs2012.usplaces5yr(keep=sumlev esriid medianhhinc state cbsatype where=(state='29' and sumlev='155' and (cbsatype ne 'Metro') and (medianhhinc >= .8* &Statemedian.) )); run; proc sort; by esriid; run; data temp.&pgm; merge educ(in=in1) income(in=in2); by esriid; if in1 and in2; run; proc sort; by county; run; ods html file="&pgm..html"; proc print label data=temp.&pgm (drop=state county sumlev); title "&pgm.: Place Level Data by County Selecting on Education and Income Criteria"; title2 'All Pcts Use Persons Over 45 as Denominator'; id areaname; var over45 medianhhinc pctover45bdegree pctover45gradpro pctover45somec pctover45hsgrad; var over45bdegree over45gradpro over45somec over45hsgrad; label pctover45bdegree='% At Least Bachelors or Associates' pctover45somec='% At Least Some College' pctover45gradpro='% Graduate or Prof Degree' pctover45hsgrad='% At Least High School'; run; ods html close;