x cd /pub/data/acs2006/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'; **==Note: a Reports subdirectory needs to be created in acs2006 prior to running since we have an ods output file in that dir-; libname btabs '/pub/data/acs2006/basetables' access=readonly; libname acs2006 '/pub/data/acs2006'; libname acspums '/pub/data/acspums'; *---step 1: create the acspums.mpr_state_interval dataset from the pums file for 2006---; 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; /* =======================Begin comment================ data aggin; set acspums.usprecs06(keep=st pwgtp povpip rename=(st=State)); where povpip ne .; length interval 3; interval=put(povpip,p72intvl.); if povpip=501 then povpip=600; *<==============NOTE: change from what we did in 2005. Trying to make this more accurate, but we do not know for sure what the value of the top-coded pov ratios were. (do we?)--; 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 "2006"; keep Year; format meanpovratio: 6.1; %mend ai; %collapse(setin=sumryout,setout=acs2006.mprintvls, byvars=state,nslots=12, colvars=meanpovratio, setmiss=1, assigni=ai, debug=0); run; proc print data=acs2006.mprintvls ; title "acs2006.mprintvls : 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=acs2006 nolist; modify mprintvls; index create State; quit; ======================End comment================== */ *----And now we create a dataset where we calculate a MeanPovRatio variable for each geographic entity on the ACS2006 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.uscensusbasetables(keep=state sumlev geoid geocomp areaname b17002i:); *---geocomp is always 00 for now------; by state notsorted; retain; if first.state then do; set acs2006.mprintvls key=State; if _iorc_ then put "***Error reading acs2006.mprintvls" / _all_; end; array _intvals_(12) meanpovratio1-meanpovratio12; *<--as read from acs2006.mprintvls --; array _countd(12) b17002i2-b17002i13; _sum=0; do i=1 to 12; if _countd{i}=. then do; if geoid ne lag(geoid) then put / geoid= areaname= ; put geoid= i= _countd{i} ' **missing values**'; end; _sum =_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 acs2006.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=acs2006.mprs(where=(geocomp='00' and RankMPR le 25)); by SumLev; format sumlev $sumlev.; id RankMPR areaname; 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;