通过格式 SAS 传递多个变量

passing multiple variables through format SAS

以下代码创建以下 table。

proc format;
value income_format
low -< 0 = "low"
1 -< 30 = "low-medium"
30 -< 60 = "average"
60 -< 90 = "high"
90 - high = "excellent";
run;



proc freq data = lib1.all;
format income income_format.; /* assign IncomeFmt format to Income variable */
tables income
/OUT = income_table outcum ;
run;

但是我想按日期对这些数据进行分组,我有每月的数据。所以我在 format 行中添加了 DATE 格式。但是,当我这样做时,我得到的返回结果完全相同 table,这是为什么?

proc freq data = lib1.all;
    format income income_format. DATE YYMMD7.; /* assign IncomeFmt format to Income variable and dateformat to date variable */
    tables income
    /OUT = income_table outcum ;
    run;

format 只告诉 SAS 如何向您显示某些内容。由于要按日期制作频率表,因此需要使用 by 语句。请务必先按日期对数据进行排序或索引。

proc freq data = lib1.all;
    format income income_format. DATE YYMMD7.; /* assign IncomeFmt format to Income variable and dateformat to date variable */
    by date;

    tables income /OUT = income_table outcum ;
run;