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).
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.