1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
data test;
input col1 $ col2 $ col3 $ col4 $ col5 $ col6 $;
cards;
id1 toto tobo tomo toko toyo
id1 toto bomo tomo toko toyo
id1 toto soso tomo toko toyo
id2 titi tati tabi tani babi
id2 titi tayi tabi tani babi
;
run;
proc sort data=test; by col2; run;
data test1 ;
set test;
by col2;
if last.col2 then output;
run;
data _null_;
set test1 end=last;
call symputx ('col1'||left(_n_),left(col1));
call symputx ('col2'||left(_n_),left(col2));
call symputx ('col3'||left(_n_),left(col2));
call symputx ('col4'||left(_n_),left(col4));
call symputx ('col5'||left(_n_),left(col5));
call symputx ('col6'||left(_n_),left(col6));
call symput ('nbr',_n_);
run;
%put &nbr;
DATA tables (drop=i);
do i=1 to &nbr;
col1=symget(cats('col1',i));
col2=symget(cats('col2',i));
col3=symget(cats('col3',i));
col4=symget(cats('col4',i));
col5=symget(cats('col5',i));
col6=symget(cats('col6',i));
output;
end;
run ;
data fin;
set test tables;
run;
proc sort data =fin;by col2; run; |
Partager