使用 SAS SQL 转置具有一行和多列的 table

Transpose a table with one row and many columns using SAS SQL

我的 table 只有 1 行和很多列。我只需要 return 1 列和许多行。可以通过 SAS SQL?

进行转置

之前:

column1 column2 column3 column4
   1       2       3       4

之后:

column
   1
   2
   3
   4

既然你提到了 SAS SQL(相对于任何其他 SAS proc),这是一个解决方案,但如果你有很多列,它会有点冗长:

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;

这只是合并(堆叠)每一列。

为什么不使用 PROC TRANSPOSE 您不必知道有多少列甚至名称 PROC TRANSPOSE 将默认转置所有数字列。

proc transpose data= out= ;
   run;