x cd /pub/data/acs/Tools; %let pgm=test_povtplus; filename pgm "&pgm..sas"; *---Experimental program to create specially collapsed version of ACS base/summary tables. Specically, those with poverty data. We want to get rid of the "Over poverty" cells but create new Pct variables for all the below poverty cells. We also support an option that allows user to specify no sex detail (so all male/female cells describing the same thing are added. J. Blodgett, OSEDA, under contract with Mo State Library. Begin 5-31-17. libname btabs '/pub/data/acs2015/basetbls'; libname user '/SAS_temp/user'; options mprint; %macro povtplus (tableID, /* base tables id such as b17002 or b17010A - case does not matter */ cell1below=2,cell1above=, /* Point to table cells where the below and above data start. */ cell1Male=0,cell1female= ); /* if interested in collapsing across sex then indicate first cells where the data for each gender occur first. */ %global ei; %if &ei=%str() %then %let ei=i; %local tabi; %let tabi=&tableid.&ei; %*--the table name followed by i or e --; %let tabli=&tableid.&ei; %local npovcells; %let npovcells=%eval(&cell1above - &cell1below); %let lastcellbelow=%eval(&cell1above -1); array &tableid(*) &tabi.: ; array Pct&tableid(&cell1below:&lastcellbelow) Pct&tabi.&cell1below - Pct&tabi&lastcellbelow; do _i=&cell1below to %eval(&cell1above - 1); _abovei=_i + &npovcells; *--add corresponding below and above cells--; _bplusa=&tableid(_i) + &tableid(_abovei); *--Assign the poverty rate variable--; if _bplusa > 0 then Pct&tableid(_i)=100*&tableid(_i)/_bplusa; end; keep &tabi.1- &tabi.&lastcellbelow Pct&tabi.: ; format Pct&tableid: 5.1; %mend povtplus; data user.b17002; set btabs.ustabs17_20 (keep=geoid areaname b17001i: b17003i: obs=1); %povtplus(b17001,cell1above=31); %povtplus(b17003,cell1above=13); put / _all_; keep _character_; run;