1
votes

I want to transform my SAS table from data Have to data want. I feel I need to use Proc transpose but could not figure it out how to do it.

data Have;
 input Stat$ variable_1 variable_2 variable_3 variable_4;
 datalines;
 MAX 6 7 11 23
 MIN 0 1 3  5
 SUM 29 87 30 100
;




data Want;
 input Variable $11.0 MAX MIN SUM;
 datalines;
 Variable_1 6 0 29  
 Variable_2 7 1 87
 Variable_3 11 3 87 
 Variable_4 23 5 100
;
1
Possible duplicate of Transpose long to wide in SASMike
duplicate most likely of stackoverflow.com/questions/52408152/…Mike
Thanks for your answer. I read all links you provided before I ask this question. They are different from what I want. Could you please help?user1481397
Looks like you just want to do a simple PROC TRANSPOSE step using STAT as the ID variable.Tom

1 Answers

1
votes

You are right, proc transpose is the solution

data Have;
 input Stat$ variable_1 variable_2 variable_3 variable_4;
 datalines;
 MAX 6 7 11 23
 MIN 0 1 3  5
 SUM 29 87 30 100
;    

/*sort it by the stat var*/
proc sort data=Have; by Stat; run;

/*id statement will keep the column names*/
proc transpose data=have out=want name=Variable;
id stat;
run;

proc print data=want; run;