对 SAS 输出中的列使用 proc 格式

Using proc format for columns in SAS output

我有以下数据

DATA HAVE;
input year dz . area;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;

使用proc freq后

proc freq data=have;
table area*dz/ list nocum ;
run;

我得到以下输出

我想用“<5”和“0”分别替换“频率”列中低于 5 的任何值和“百分比”列中低于 0 的任何值。

我有下面的 proc 格式代码

 proc format;
picture count (round)
0-4 = ' <5' (NOEDIT);
picture pcnt (round)
0 = ' - '
other = '009.9%';

但我不明白如何在数据步骤中使用它来获得所需的结果。请指导。

谢谢!

您可以将 proc freq 的结果保存为数据集,然后根据需要进行报告。

proc freq data=have noprint;
  table area*dz/ list nocum out = want;
run;

proc print;
  format COUNT count. PERCENT pcnt.;
run;

如果您想要 proc freq 输出结果如您所愿,而不是使用额外的报告或打印程序,您需要多编写一些代码。答案是关于 ods 样式的,关于它有一篇非常好的文章:Using Styles and Templates to Customize SAS® ODS Output