Hello
I am using Proc Transpose from wide to long.
There are 2 things that I want to ask please:
question 1;
Why in the data set ttt2 column name is "X1"?
I want to call it "X
question 2:
I want to rename Column _Name_ to 'date'
I want that values will be
1909
1908
1907
1906
1905
and not
X1909
X1908
X1907
X1906
X1905
Data ttt1;
Input ID X1909 X1908 X1907 X1906 X1905;
cards;
1 10 25 32 40 51
2 12 14 6 18 20
3 15 22 27 33 22
;
run;
/*ID date X*/
/*1 1909 10*/
/*1 1908 25*/
/*1 1907 32*/
/*1 1906 40*/
/*1 1905 51*/
/*2 1909 12*/
/*2 1908 14*/
/*2 1907 6*/
/*2 1906 18*/
/*2 1905 20*/
/*3 1909 15*/
/*3 1908 22*/
/*3 1907 27*/
/*3 1906 33*/
/*3 1905 22*/
proc transpose data =ttt1 out= ttt12 prefix=X;
by ID;
var X1909 X1908 X1907 X1906 X1905;
run;
You can do the renaming like this
proc transpose data =ttt1 out= ttt12(rename=(_Name_=date));
by ID;
var X1909 X1908 X1907 X1906 X1905;
run;
As for removing the 'X'.. This is a data manipulation question. Not a job for PROC TRANSPOSE. i would simply add a data step
data ttt13;
set ttt12;
date=compress(date, , 'kd');
run;
You can do the renaming like this
proc transpose data =ttt1 out= ttt12(rename=(_Name_=date));
by ID;
var X1909 X1908 X1907 X1906 X1905;
run;
As for removing the 'X'.. This is a data manipulation question. Not a job for PROC TRANSPOSE. i would simply add a data step
data ttt13;
set ttt12;
date=compress(date, , 'kd');
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.