You can use proc sql and sashelp.vcolumn to get the number of transposed columns, in fact you get the number of columns starting with 'Col'. The following code creates a global macro-variable maxColumns, afterwards the variable is used to create an array statement. The code is untested.
[pre]proc sql noprint;
select count(*)
into :maxColumns
from sashelp.vcolumn
where lowcase(libname) = 'your_lib' and
lowcase(memname) = 'your_dataset' and
name like 'Col%'
;
quit;[/pre]
[pre]data _null_;
set dataset;
array cols{&maxColumns} col1-col&maxColumns;
do i=1 to &maxColumns by 1;
put cols{i};
end;
run;[/pre]
... View more