02-19-2015 04:27 PM
I have several columns with column names like this:
A B C D E F G.....
what I want to do is to create new columns as A+B,A+C, A+D... and then B+C, B+D, B+E, ... and C+D, C+E, C+F...
I need to repeat this process for many times. Anyone can give me a hint how to write macro on this?
02-19-2015 05:38 PM
I would use PROC SCORE
Message was edited by: data _null_
02-19-2015 05:42 PM
You might need macro code (or at least some method to generate macro variables) to make up meaningful names, but to make the sums you can do with straight SAS code.
%let names=a b c d e ;
set have ;
array single (&n) &names ;
array double (&n,&n) ;
do i=1 to &n ; do j=i+1 to &n ;
double(&i,&j) = single(&i) + single(&j);