x cd /pub/data/acspums/Tools; %let pgm=application_avghhincomes; filename pgm "&pgm..sas"; *---acspums Excample 01. jgb, 6/2006. Client: Minxia D. Data requested: ( 1) total number of children living in Missouri in 2004 ( 2) the average household income for married couples living in Missouri in 2004 ( 3) the average income for single parent households Missouri in 2004 ( 4) the average income for single parent households in the United States in 2004 The anser to 1 was best done using the latest estimates by age from the Bureau. We are able to estimate the other 3 items from pums. Simple enough to be done in a data step, which we incorporate into a macro, for ease of running the exact same code except for the dataset (mo or us) being referenced. ---*; title "&pgm: Various Average Household Income Figures for Missouri and US"; %libname (acspums); %macro doit(ss); data _null_; set acspums.&ss.hrecs04 end=last; married_couple = ('1' <= fes <= '4'); single_parent_fam = not married_couple and ('1' <=fparc <='3'); if married_couple then do; _nmc + wgtp; _mctotalincome + fincp*wgtp; end; else if single_parent_fam then do; _nsp + wgtp; _sptotalincome + fincp*wgtp; end; if last then do; file print; title "&pgm.: Results for &ss"; retain SS "&ss"; AvgHHI_MarriedCouples=_mctotalincome/_nmc; AvgHHI_SingleParentFams=_sptotalincome/_nsp; format Avg: dollar10.; put AvgHHI_MarriedCouples= +3 AvgHHI_SingleParentFams= / _all_; end; run; %mend doit; %doit(mo) ; %doit(us) ;