SAS Proc Freq 显示类别和计数 [英] SAS Proc Freq display categories with counts

查看:11
本文介绍了SAS Proc Freq 显示类别和计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道如何在基本 SAS 中完成以下操作.我有以下代码.

Wondering how this following can be done in base SAS. I've got the following code.

libname SASData  '/folders/myfolders/Datafiles';

data chap9ques6;
    set SASData.medical(keep=VisitDate);

    DayOfWeek = weekday(VisitDate);
run;

proc format;
    value Days 1='Sunday' 2='Monday' 3='Tuesday' 4='Wednesday' 5='Thursday' 6='Friday' 7='Saturday';
run;

proc freq data=chap9ques6;
    tables DayOfWeek /nocum nopercent missprint;

    Format DayOfWeek Days.;
run;

这样会产生可接受的结果.

Which produces an acceptable result like this.

FREQ 过程

DayOfWeek 频率

DayOfWeek Frequency

星期天 1

星期一 1

星期四 1

星期五 1

星期六 2

与示例 SAS 数据一起使用时.我想要的是在列表中包含其他工作日,即使它们没有匹配的行.周二 0 周三 0"

when used with the sample SAS data. What I'd like to to is include the other weekdays in the list even though they don't have matching rows. "Tuesday 0 Wednesday 0"

如何在最终输出中包含这些行?

How can I include those rows in the final output?

推荐答案

您可以使用您创建的 DAYS 格式来提供有关您要报告的天数总体"的信息.PROC FREQ 不直接支持使用 PROC Summary 或 PROC TABULATE 从无到有的创建.在这个例子中,我使用了带有 WEIGHT 语句和 ZEROS 选项的 PROC Summary 和 PROC FREQ.

You can use the DAYS format you created to supply the information on the "population" of days you want to report. PROC FREQ does not directly support the creation of something from nothing that can be done with PROC SUMMARY or PROC TABULATE. In this example I use PROC SUMMARY and PROC FREQ with WEIGHT statement and the ZEROS option.

data chap9ques6;
   DayOfWeek = 3;
   run;

proc format;
   value Days 1='Sunday' 2='Monday' 3='Tuesday' 4='Wednesday' 5='Thursday' 6='Friday' 7='Saturday';
   run;
proc summary data=chap9ques6 nway completetypes;
   class dayofweek / preloadfmt;
   format dayofweek days.;
   output out=counts;
   run;
proc print;
   run;

proc freq data=counts;
   tables DayOfWeek /nocum nopercent missprint;
   Format DayOfWeek Days.;
   weight _freq_ / zeros;
   run;

这篇关于SAS Proc Freq 显示类别和计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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