Well this is one way of doing it[pre]
data input;
length a b c d $1;
input a b c d;
datalines;
x x x x
y y y y
z z z z
x x x x
;
run;[/pre][pre]
* find variable names, number of varibales and number of obs *;
proc sql NOPRINT;
select name into :varnames SEPARATED by ','
from sashelp.vcolumn
where libname = 'WORK' and memname = 'INPUT';
select nobs into :nobs
from sashelp.vtable
where libname = 'WORK' and memname = 'INPUT';
select nvar into :nvar
from sashelp.vtable
where libname = 'WORK' and memname = 'INPUT';
quit;;[/pre][pre]
* create list with new variables *;
data _null_;
length _x_ $2000;
do vars = 1 to &nvar.;
do obs = 1 to &nobs.;
_x_ = catx(' ',_x_,cats(scan("&varnames.",obs,','),vars));
end;
end;
call symput('varlist',strip(_x_));
run;;[/pre][pre]
* transpose input data into one record *;
data transposed(keep=&varlist.);
retain &varlist.;
array vars{&nvar.,&nobs.} $1. &varlist.;
set input end=last;
do i = 1 to &nvar.;
x=scan("&varnames",i,',');
y=vvaluex(x);
vars{_n_,i}=vvaluex(x);
end;
if last then do; output; end;
run;
[/pre]