SAS-为什么C是正确答案?

时间:2017-12-01 09:02:22

标签: sas format

proc format;
value salfmt.
0 -<50000 = "Less than 50K"
50000 - high = "50K or Greater";
options fmterr nodate pageno=1;
title "C";
proc print data= work.emp noobs;
var fullname salary hiredate;
format 
salary salfmt.
hiredate date9.;
label fullname = "X"
salary = "Y"
hiredate = "Z";
run;

为什么程序失败?

  • 甲。 OPTIONS语句中的PAGENO选项无效。
  • B中。 FORMAT过程后缺少RUN语句。
  • ℃。格式名称包含VALUE语句中的句点。
  • d。 PROC PRINT语句中缺少LABEL选项。

2 个答案:

答案 0 :(得分:2)

proc format中创建格式时,您可以为该格式指定名称,例如您的示例中的salfmt。要在以后引用此格式,您需要在格式名称的末尾添加句点.,以告诉SAS它是一种格式。

创建格式时,此期间不是必需的,也不是有效的,这就是C是正确答案的原因

答案 1 :(得分:0)

对我来说,似乎Proc format有点偏。以下是合作的。 (不得不为我自己更改数据集,但逻辑是可靠的。)

proc format;
    value salfmt
    0 -<50000 = "Less than 50K"
    50000 - high = "50K or Greater";
quit;

options fmterr nodate pageno=1;
title "C";

proc print data= in_out noobs;
    var price; 
    format  price salfmt. ;
run;

总的来说,如果你想创建字符串,语法会有所不同:

proc format; 
    value $populated
    0 = '0'
    . = 'missing'
    other ='Not zero';

    value populated 
    0 = '0'
    other ='Not zero';
quit;

有关proc格式的详情,请查看SAS documentation

相关问题