对SAS输出中的列使用proc格式 [英] Using proc format for columns in SAS output

查看:48
本文介绍了对SAS输出中的列使用proc格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下数据

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

使用proc freq后

After using the proc freq

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

我得到以下输出

我要替换频率"中小于5的任何值.列和百分比"中的0.列中带有< 5"的列和"0".

I want to replace any values below 5 in "frequency" column and 0 in "percent" column with "<5" and "0", respectively.

我有以下proc格式代码

I have the below proc format code

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

但是我不理解如何在数据步骤中使用它来获得所需的结果.请指导.

But I am not understanding how to use it in the data step to get the desired results. Please guide.

谢谢!

推荐答案

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

You can save the result of proc freq as a dataset then report it as your wish.

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

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

如果您希望按自己的意愿 proc freq 输出结果,而不使用额外的报告或打印过程,则需要多编写一些代码.答案与ods样式有关,并且有一篇非常不错的文章:

If you want your proc freq output result just as your wish, not using an extra report or print procedure, you need to code a little more. The answer is about ods style and there is a very nice article about it: Using Styles and Templates to Customize SAS® ODS Output

这篇关于对SAS输出中的列使用proc格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆