Hi, I'm transposing the data with Proc summary and the code is as below -
data have; input PT DT RULE_ID RULE_CAT; cards; 1 10 20 20 1 10 21 20 1 10 22 20 1 10 23 20 1 11 20 20 1 11 21 20 1 11 22 20 1 11 23 20 1 12 20 20 1 12 21 20 1 12 22 20 1 12 23 20 2 10 20 20 2 10 21 20 2 10 22 20 2 10 23 20 2 11 20 20 2 11 21 20 2 11 22 20 2 11 23 20 2 12 20 20 2 12 21 20 2 12 22 20 2 12 23 20 ;;;; run;
proc sql noprint feedback; select max(ptcount) into :dim from (select count(PT) as ptcount from have group by PT, DT); quit; run; OPTIONS SYMBOLGEN; proc summary data=have nway; class PT DT; output out=need idgroup(out[&dim](RULE_ID: RULE_CAT: )=); run;
With the above code my final dataset need looks like below.
So the question now is - columns need to be rearranged like, RULE_ID_1, RULE_CAT_1, RULE_ID_2, RULE_CAT_2,RULE_ID_3, RULE_CAT_3,RULE_ID_4, RULE_CAT_4.
Is this possible? Because the number of columns getting created is random and based on the value of the macro variable dim getting created from Proc Sql.
Please share your views and suggestions.
... View more