How to easly reformat dataset in SAS -
suppose data follows:
a b c 1 3 2 1 4 9 2 6 0 2 7 3 where b , c variable names.
is there way transform table to
a 1 1 2 2 b 3 b 4 b 6 b 7 c 2 c 9 c 0 c 3
expanding on advice @donpablo, here's how code it. create array read across data, output each iteration of array end number of rows being rows * columns original dataset. vname function enables store variable name (a, b, c) value in separate variable.
data have; input b c; datalines; 1 3 2 1 4 9 2 6 0 2 7 3 ; run; data want; set have; length var1 $10; array vars{*} _numeric_; i=1 dim(vars); var1=vname(vars{i}); var2=vars{i}; keep var1 var2; output; end; run; proc sort data=want; var1; run;
Comments
Post a Comment