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).
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.