x cd /pub/data/acs2010/Tools; %let pgm=application_povertybybgs2; filename pgm "&pgm..sas"; *---Note the "2" in pgm name! Add state indexes to povert data at BG level for Boone county. Look at distribution of indices and use to create interval codes to be used in Lance Huntley's choro maps.---; libname acsbtabs '/pub/data/acs2010/basetbls'; *--once we used: /Missouri_Illinois_Kansas ; libname user '/SAS_temp'; libname temp '/pub/data/temp'; title "Alternate Measures of Income and Poverty for Boone County, Missouri"; title2 "Defining State Indices of Key Variables to be Mapped"; options mprint ; /* ========================begin comment==================================== ==========================end comment====================================== */ data motots; set acsbtabs.motabs17_205yr(keep=sumlev state geocomp geocode b01001i1 b17010i: c17002i: b17017i: b17021i: b19001i: b19013i: b19113i: b19202i: ); where state='29' and sumlev='040' and geocomp='00'; TotPop=B01001i1; TotHHs=B19001i1; MedianHHInc=B19013i1; PovUniverse=c17002i1; Poor=c17002i2+ c17002i3; if PovUniverse then PctPoor=100*Poor/PovUniverse; FamHHs=b17010i1; NonFamHHs=TotHHs-FamHHs; PoorFamHHs=b17010i2; if FamHHs then PctPoorFamHHs=100*PoorFamHHs/FamHHs; PoorNonFamHHs= B17017i20; if NonFamHHs then PctPoorNonFamHHs=100*PoorNonFamHHs/NonFamHHs; MedianFamInc=b19113i1; MedianNonFamInc=b19202i1; PersonsInFamilies=b17021i3 + b17021i20 - sum (of b17021i6 b17021i10 b17021i13 b17021i23 b17021i27 b17021i30); PoorPersonsInFamilies=b17021i3 - sum (of b17021i6 b17021i10 b17021i13); *--subtract non-relatives living in family hhs--; if PersonsInFamilies then PctPoorPersonsInFamilies=100*PoorPersonsInFamilies/PersonsInFamilies; Under185Pov=sum(of c17002i2--c17002i6); if PovUniverse then PctUnder185Pov=100*Under185Pov/PovUniverse; *---another attempot at mean poverty ratio used best available data--; if PovUniverse then MeanPovRatio=(c17002i2*.25 + c17002i3*.75 + c17002i4*1.125 + c17002i5*1.375 + c17002i6*1.675 + c17002i7*1.925 + c17002i8*3)/PovUniverse; keep sumlev geocode TotPop--MeanPovRatio; format pct: 5.1; format MeanPovRatio 5.3; label MeanPovRatio="Mean Poverty Ratio (est)"; run; %genrenam(user.motots,sfx=_mo); %*---generates value of macro parm rename with rename specs for this dataset--; data motots; set motots( &rename); run; %let indices=; data temp.indices; set temp.booneco_bgpoverty ; if _n_=1 then set motots; retain %varlist(*_mo,user.motots) ; %macro indx(var); %global indices; &var._stindex=&var./&var._mo; keep &var &var._stindex; %let indices=&indices &var._stindex; %mend indx; %indx(MedianHHInc) %indx(MedianFamInc) %indx(PctPoor) %indx(PctPoorFamHHs) %indx(PctPoorPersonsInFamilies) %indx(PctUnder185Pov) %indx(MeanPovRatio) keep TotHHs esriid ; run; %put indices=&indices; %macro olist(var,desc=); %let indx=&var._stindex; proc sort data=temp.indices(keep=&var &indx esriid totHHs) out=sorted&var ; by &desc &indx ; proc print; var &indx &var TotHHs esriid; format &indx 7.2 ; title2 "&var"; run; %mend; %olist(MedianHHinc) ; %olist(medianFamInc) ; %olist(PctPoor,desc=descending); %olist(PctPoorFamHHs,desc=descending) %olist(PctPoorPersonsinFamilies,desc=descending) %olist(PctUnder185Pov,desc=descending) %olist(MeanPovRatio,desc=descending)