Hello, a data step solution: data have; input A_id A_Amount A_Stage $ A_week $ ; datalines; 1 2123 first wk_1 2 234324 first wk_1 3 232 first wk_1 4 1 first wk_1 5 1123 first wk_1 1 3242 second wk_2 2 324255 second wk_2 3 2342 second wk_2 4 4324 second wk_2 1 242424 third wk_3 2 43242 third wk_3 3 424 third wk_3 4 242 third wk_3 1 4 fourth wk_4 2 243 fourth wk_4 3 2 fourth wk_4 ; proc sort data=have; by a_id; run; proc sql noprint; select count(distinct A_week) into :cvals from have; quit; data want (drop=i a_stage a_amount a_week); array A_week_{&cvals} $; array A_Stage_{&cvals} $; array A_Amount_ {&cvals} ; do until(last.a_id); set have; by a_id; i=sum(i,1); A_week_{i}=A_week; A_Stage_{i}=A_Stage; A_Amount_{i}=A_Amount; end; run;
... View more