Below is a way to do it using a macro and the Transpose Procedure and then merging the transposed data sets together. It should get you what you are looking for in the output data. If arrays are required, that can be adjusted too.
data have;
input ID$ Time X Y Z;
datalines;
1 10 1 2 3
1 11 4 5 6
1 12 7 8 9
2 13 10 20 30
2 14 . . .
2 15 40 . 50
3 16 15 . .
3 17 25 36 37
3 18 35 36 37
;
run;
proc sort data=have;
by ID;
run;
%macro transpose(var,n);
%if &n^=3 %then %do;
proc transpose data=have prefix=&var out=want_&var (drop=_NAME_);
by ID;
var &var;
run;
%end;
%else %do;
proc transpose data=have prefix=&var out=want_&var (drop=_NAME_);
by ID;
var &var;
run;
data want;
merge want_X want_Y want_&var;
run;
%end;
%mend;
%transpose(X,1)
%transpose(Y,2)
%transpose(Z,3);
I think you can find the solution in this article (see Example 1 there).
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.