Transposing wide to long in SAS, without extra columns

后端 未结 3 1462
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-25 07:48

I\'d like to transpose a dataset, but SAS insists on adding a new column, if the \"by\" column has multiple entries.

So if I run

data test;
    input a b         


        
3条回答
  •  后悔当初
    2021-01-25 08:12

    data output;
    set test;
    array vars {*} b -- c; * define array composed of list of variables from B to C, have to be of same type;
    
    length varname $32;
    keep a varname value;
    
    do i=1 to dim(vars);* loop array (list of variables);
        varname= vname(vars(i));* get name of variable that provided value;
        value = vars(i);* get the value of variable;
        output; *output row;
    end;
    run;
    

提交回复
热议问题