x cd /pub/data/acs2005/Tools; %let pgm=mean_poverty_ratios; filename pgm "&pgm..sas"; *---calculate mean poverty ratios, derived from base table b17002. We use the acspums dataset to create a table of mpr values per state per poverty ratio interval as used in table b17002. ----; title 'Mean Poverty Ratios Assigned by the Missouri Census Data Center'; libname btabs '/pub/data/acs2005/basetabs' access=readonly; libname acs2005 '/pub/data/acs2005'; libname acspums '/pub/data/acspums'; /* =======================Begin comment================ *---step 1: create the acspums.mpr_state_interval dataset from the pums file for 2005---; proc format; value p72intvl 0-49=1 50-74=2 75-99=3 100-124=4 125-149=5 150-174=6 175-184=7 185-199=8 200-299=9 300-399=10 400-499=11 500 - high=12; run; data aggin; set acspums.usprecs05(keep=st pwgtp povpip rename=(st=State)); where povpip ne .; length interval 3; interval=put(povpip,p72intvl.); run; proc summary data=aggin; freq pwgtp; class state interval; var povpip; output out=sumryout mean=meanPovRatio; run; proc sort; by state interval; run; %macro ai; if interval=. then go to cklast; else _i_=interval; drop interval; retain Year "2005"; keep Year; format meanpovratio: 6.1; %mend ai; %collapse(setin=sumryout,setout=acs2005.&pgm, byvars=state,nslots=12, colvars=meanpovratio, setmiss=1, assigni=ai, debug=0); run; proc print data=acs2005.&pgm ; title "acs2005.&pgm : Mean Poverty Ratios by State and the 12 Poverty-Ratio Intervals in Table b17002"; title2 "Values Based on Extraction from acspums.usprecs05"; run; proc datasets library=acs2005; modify &pgm; index create State; quit; ======================End comment================== */ *----And now we create a dataset where we calculate a MeanPovRatio variable for each geographic entity on the ACS2005 list. We use the counts in the b17002 table which we multiply by the mean value of the pov ratios for that interval for the state, and then we divide by the total N for the table (cell 1) to get the overall mean. Because of top-coding of the 5+ (last) interval this value will not be very accurate for areas where there are large numbers for the final interval. In fact, the numbers should be more accurate for areas with lower incomes because the intervals are smaller for lower incomes. -----*; data mprs; set btabs.b17002 (drop=marg: pct:); by state notsorted; retain; if first.state then do; set acs2005.&pgm key=State; if _iorc_ then put "***Error reading acs2005.&pgm " / _all_; end; array _intvals_(12) meanpovratio1-meanpovratio12; *<--as read from acs2005.mean_poverty_ratios --; array _countd(12) b17002i2-b17002i13; _sum=0; do i=1 to 12; _sum + _countd{i}*_intvals_{i}; end; MeanPovRatio=_sum/b17002i1; *if _n_ le 3 then put / _all_; * else stop; keep _character_ b17002i1 MeanPovRatio; format MeanPovRatio 5.1; run; proc sort; by Geocomp SumLev descending MeanPovRatio; run; data acs2005.mprs(label='Mean Poverty Ratios With US Ranks for all geographies from base table b17002' index=(geoid)); set mprs; by geocomp sumlev; if first.sumlev then RankMPR=1; else RankMPR +1; label RankMPR='Mean Pov Ratio Rank in US Within Summary Level & geocomp'; run; ods html file="../Reports/&pgm..html" style=sasweb; proc print data=acs2005.mprs(where=(geocomp='00' and RankMPR le 25)); by SumLev; format sumlev $sumlev.; id RankMPR name; var MeanPovRatio; title2 'Highest Ranking Areas (Top 25 per Geographic Summary Level) Based on Mean Poverty Ratio'; title3 'Geographic Component Areas Not Shown'; run; ods html close;