2017-08-30 62 views
0

我正在使用SAS并试图自动获取今天的日期并将其放入proc freq的where子句中。SAS - today()in proc freq where子句

它看起来喜欢这样的:

proc freq data=data_name; 
    tables date_col; 
    where date_col > '30aug2017'd; 
run; 

相反30aug2017的今天我(想),但我在努力得到这个工作,我已经试过:

data create_date; 
current1 = today(); 
format current1 date9.; 
run; 

proc freq data=data_name; 
    tables date_col; 
    where date_col > current1; 
run; 

但错误我得到的是该变量不在文件

赞赏任何帮助,

欢呼家伙

回答

0

您可以直接在您的WHERE语句中使用TODAY()。

where date_col > today(); 
+0

我曾尝试过,并认为它没有奏效。刚刚意识到这是因为数据今天不可用...... – Sunny

+1

我建议使用'%sysfunc(today())'来避免函数在每个记录上触发 –

+0

很常见,我使用x天的时间段:date_col> date() - 20,这里的x是20。 – pinegulf