我如何在SAS中写下减去日期的过滤器
您好Stackoverflow社区...希望您可以为这个SAS问题提供帮助。
我需要为表格创建一个过滤器,该表仅退还那些从去年前进的记录。
我想获得类似的内容:
data want;
set have;
where expire_date >= current(date) - 1year:
run;
Expire_Date列的格式为03May2022(date9。format)...我尝试将日期转换为数字,然后减去365,但我想有一个更好的解决方案。
有人可以照亮我吗?
提前致谢
Hello Stackoverflow community... hope you can help with this sas question.
I need to create a filter for a table which gives back only those records that are active from last year forward.
I would like to obtain something like :
data want;
set have;
where expire_date >= current(date) - 1year:
run;
the format of the expire_date column is 03MAY2022 (date9. format)... I tried to transform the date into a number and then subtracting 365, but i guess there is a better solution.
can someone illuminate me?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在搜索intnx()函数:
输出:
I think you are searching for the INTNX() function:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p10v3sa3i4kfxfn1sovhi5xzxh8n.htm#n1lchasgjah7ran0z2wlmsbfwdx2
For example:
Output:
您可以使用date()函数获取当前日期。
您想要一年或365天吗?
使用日期间隔使用intnx()函数。
要使用固定的天数,只是减去数字。
You can get the current date using the DATE() function.
Do you want one YEAR or 365 days?
To use a date interval use the INTNX() function.
To use a fixed number of days just subtract the number.