Here is what I came up with:
data _null_;
set exp (obs=0) nobs=nobs;
call symputx("nobs", nobs);
run;
proc transpose data=exp out=exp2;
run;
data exp3(keep=row final);
set exp2;
array col{&nobs};
do i = 1 to &nobs;
if col[i] ne . then do;
row+1;
if row = &nobs+1 then row = 1;
final = col[i];
output;
end;
end;
run;
proc sort data=exp3;
by row;
run;
proc transpose data = exp3 out=exp4 (drop=_name_ row
rename=(col1=x col2=y col3=z col4=zz));
by row;
run;
First I counted the observations in the starting data set and stored that to a macro variable (if you know it is always 5 you can skip this step and replace &nobs with 5). Then I transposed the data set so it is rotated 90 degrees. This allows me to then go through each number in order and output it to one long row, also adding a number for the row we want it to be in in the final output. Finally I transposed by row number to get the final output.