My table has only 1 row and many columns. I need to return only 1 column and many rows. It is possible to do a transpose via SAS SQL?
Before:
column1 column2 column3 column4
1 2 3 4
After:
column
1
2
3
4
My table has only 1 row and many columns. I need to return only 1 column and many rows. It is possible to do a transpose via SAS SQL?
Before:
column1 column2 column3 column4
1 2 3 4
After:
column
1
2
3
4
Since you mention SAS SQL (as opposed to any other SAS proc), this is a solution, though it will be a bit verbose if you have a lot of columns:
PROC SQL;
SELECT column1 AS column FROM table
UNION ALL
SELECT column2 AS column FROM table
UNION ALL
SELECT column3 AS column FROM table
UNION ALL
SELECT column4 AS column FROM table;
/* Add for each column */
QUIT;
This simply unions (stacks) each column.
Why not use PROC TRANSPOSE you don't have to know how many columns or even the names PROC TRANSPOSE will transpose all numeric columns by default.
proc transpose data= out= ;
run;