I have an observation and I need to make a column

2019-09-21 08:05发布

问题:

I have an observation and I need to make a column with SAS I tried split, I tried transpose, but nothing...

I have:


   num first second third
    1     13     17     16
    2     23     11     64

I need:


 num  var_n
   1  13
      17
      16
   2  23
      11
      64

Can you give me some advice, please

回答1:

Proc Transpose is already the right step to get your data in shape. Proc report is only used to display IDs only once.

data wide;
   input num first second third;
   datalines;
    1     13     17     16
    2     23     11     64
    ;
run;

proc transpose data = wide out= long (rename=(col1 = var_n)) ;
    by num;
    var first second third;
run;

proc report data = long;
    column num  var_n;
    define num/ order;
run;


回答2:

This is essentially the third time you've asked the same question. You can use proc transpose or proc sql to get it done.

See your other post: How to make a column of three. SAS



回答3:

try the following

proc sort data=dataset;
   by num;
run;

proc transpose data=dataset out=transpose;
   by num;
   var first second third;
run;

thanks



标签: sas