0

通常在 sas proc 报告中,我们可以使用 byvar/byval 将 by 类别放在显示的顶部。在我的情况下,我的显示有 2 个类别。我不知道该怎么做。我可以使用 proc 报告添加一个,但我不知道如何添加 2。

我希望我的显示如下:

性别:男性 (100) 治疗:阿司匹林 (40mg) (N=21)

列 1 列 2 列 3

4

1 回答 1

0

预先计算组大小并将该变量添加到 by 分组中。在单个TITLE或多个TITLE1 TITLE2语句中使用内联样式。

例子:

data have;
  call streaminit (2021);
  do g1=1 to 3;
  do g2=1 to 3;
    do _n_ = 1 to rand('integer', 5);
      pid + 1;
      array c col1-col3;
      do over c; z+1; c=z; end;
      output;
    end;
  end;
  end;
  drop z;
run;

options nodate nonumber nocenter nobyline;
ods escapechar='^';

proc sql;
  create table reportdata as
  select *, count(*) as count from have group by g1, g2 order by g1, g2, col1;

proc report data=reportdata;
  title '#byvar1: #byval1^n#byvar2: #byval2 (n=#byval3)';
  by g1 g2 count;
  columns col1-col3;
  define col1-col3/display;
run;

输出:

在此处输入图像描述

于 2021-09-13T01:47:30.100 回答