x cd /mscdc/data/stf903/Tools; %let pgm=agg_median_hhinc; filename pgm "&pgm..sas"; title 'Aggregate Median Household Income by Aggregating Table P80'; options ls=80 ps=240 nocenter; *--aggregte the medina household income by aggregating corresponding hh income distribution table and then apply special macro to appxmate from distr. jgb, 7-1-98. Originally coded as custor request for Missouri Innovation Ctr, Inc. Quinten Messbarger. --*; %libname(stf903) libname user '/tmp/storage/user'; /* *<============commenting======= data aggint; set stf903.motrbnas(keep=slvl county tract p80i1-p80i25 p80ai1 p5i1); where county='29019'; where also ('0001.00' le tract le '0010.00') or tract in ('0011.01','0013.00','0014.00','0015.01','0015.02'); run; data agginbg; set stf903.mobg1740(keep=slvl county tract bg p80i1-p80i25 p80ai1 p5i1); where county='29019'; where also tract='0011.04' and bg='3'; run; data aggin/view=aggin; set aggint agginbg; put tract= bg=; run; %agg(aggin=aggin,aggout=aggout, aggvars=p80i1-p80i25 p80ai1 p5i1, means=p80ai1, mweights=p5i1, grand=only) run; ================== */ data final; set aggout; RETAIN P107W1-P107W2 5000 P107W3-P107W18 2500 P107W19-P107W20 5000 P107W21 15000 P107W22-P107W24 25000 P107W25 50000; array p107w p107w1-p107w25; ARRAY P80C P80I1-P80I25; *<--COUNTS FROM P80. SHARE P107W WIDTHS; %MEDIAN(INTSIZE=P107W,INTVALS=P80C,MDN=medhhinc) *--WE DO NOT WANT THESE ON OUTPUT DATA SET--; *DROP P107W1-P107W25 ; put _all_; run;