【问题标题】:SAS, switch rows and columns, for resultsSAS,切换行和列,以获得结果
【发布时间】:2021-06-08 00:46:01
【问题描述】:

如果有办法,我想重新格式化我的打印结果。

运行 proc 后得到的意思是:

Yearㅣ  #  ㅣ Variable  ㅣ   N ㅣMean
-------------------------------------
1991ㅣ  x  ㅣ   AAAAA   ㅣ   x ㅣ x
1991ㅣ  x  ㅣ   BBBBB   ㅣ   x ㅣ x
1991ㅣ  x  ㅣ   CCCCC   ㅣ   x ㅣ x
1992ㅣ  x  ㅣ   AAAAA   ㅣ   x ㅣ x
1992ㅣ  x  ㅣ   BBBBB   ㅣ   x ㅣ x
1992ㅣ  x  ㅣ   CCCCC   ㅣ   x ㅣ x
1993ㅣ  x  ㅣ   AAAAA   ㅣ   x ㅣ x
1993ㅣ  x  ㅣ   BBBBB   ㅣ   x ㅣ x
1993ㅣ  x  ㅣ   CCCCC   ㅣ   x ㅣ x

我想更改此结果表,以便 1991 1992 1993 是列 我希望这些行显示为:

AAAAA
N
Mean
BBBBB
N
Mean
CCCCC
N
Mean

谢谢。

【问题讨论】:

  • 恐怕你对你想要的东西的规范并不准确。请详细说明。
  • 请注意,我在您的问题中引入了代码块,因此它变得更加紧凑和可读。
  • 有很多东西要“得到”。显示您提交的Proc MEANS 步骤的代码。

标签: sas row transpose


【解决方案1】:

对于显示的输出(相对于生成的输出数据集),您可以使用Proc TABULATE 轻松安排您的演示文稿。

SASHELP.FISH 是 SAS 样本数据集,其布局可能与您的数据相同。

例子:

明智的演示,在FISH 中,变量species 将对应于您的YEAR

比较MEANS 输出和TABULATE 输出。数字相同,但显示方式不同(行而不是列中的统计数据)。

proc means data=sashelp.fish n mean ;
  class species;
  var weight height width;
  where species =: 'P';  * limit for demonstration;
run;


proc tabulate data=sashelp.fish;
  title "Tabulate";  
  title2 font=courier "(weight height width) * (n mean) , species";

  class species;
  var weight height width;

  table (weight height width) * (n mean) , species;

  where species =: 'P';  * limit for demonstration;
run;

将产生这两个输出

【讨论】:

    【解决方案2】:

    试试这个。它可能不是你想要的,但它可能很接近。

    proc sort data=WHAT_I_HAVE;
    by variable year;
    
    proc transpose data=WHAT_I_HAVE out=WHAT_I_NEED;
    by variable;
    id year
    var n mean;
    run;
    

    免责声明:这是未经测试的代码,可能需要调试。

    【讨论】:

      猜你喜欢
      • 2012-08-31
      • 1970-01-01
      • 2013-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-06
      相关资源
      最近更新 更多