Skip Navigation

UNC Carolina Population Center

 

Data Management tips and tricks

Merge a single observation data set to every observation of a multi-observation data set.


proc summary nway data=income;
  var yr_income;
  output out=avg_income (drop= _type_ _freq_)
          mean=avg_yr_income;
run;


data income;
  if _N_ = 1 then set avg_income(keep = avg_yr_income);
  set income;
run;

** NOTE:  This method re-orders the variables in your data set such that avg_yr_income will be the first variable. **;

Another topic?
Questions or comments?  If you are affiliated with the Carolina Population Center, send them to Phil Bardsley.