04-25-2017 01:45 PM
i am trying to rename two variables with different names as same new name
rename A as x and rename B as X in same data set.
i m performing concatenationof 2 data set using "set" and trying to rename the variables A, B as X(original name in one data set);
i am writing code as:
Set red red2 (rename=(A = x));....working
Set red red2 (rename=(A=x B=x));......not working.
04-25-2017 02:14 PM
Each data set named can have its own data set options. So this might be what you are looking for:
set red (rename=(b=X)) red2 (rename=(a=X));
If this is the right idea, it would be a requirement that A and B are the same type (either both numeric, or both character).
04-25-2017 02:46 PM
Sounds like you want to tranpose the data to convert two columns into two rows.
But for this simple example just set the original dataset twice.
data want ; set have (keep=A rename=(A=X)) have (keep=B rename=(B=X)) ; run;
So if you had:
A B 1 2 3 4 5 6
You would get
X 1 3 5 2 4 6