0

我有这段代码,我根据今天的日期为日期创建 proc 格式语句。今天之前的任何日期都是红色的,未来的任何日期都是绿色的。但是,这是我在其中调用此语句的 proc 报告,并且在某些情况下 date 存在空白值。因此,我希望不包含日期的字段为白色。

data _null_;
sdate = date ();
format sdate date9.;
call symput('sdate',sdate);
run;

proc format;
  value closefmt 
    low - &sdate ='red'
    ' ' = 'white'
    &sdate - high = 'green';

run;

它不喜欢 ' ' = white 并且不接受 null。任何帮助,将不胜感激。提前致谢。

4

1 回答 1

0

Use single dot for missing values in numeric variable:

proc format;
  value closefmt 
    low - &sdate ='red'
    . = 'white'
    &sdate - high = 'green';

run;

/* test code */
data indata;
    d = .; output;
    do i=-3 to 3;
       d = today()+i;
       output;
    end;
run;

data _null_;
    set indata;
    format d yymmdds10.;
    length color $10;
    color = put(d, closefmt. - L);
    putlog d color;
run;
于 2013-11-07T12:38:56.990 回答