[英]Flag rows in a SAS table dated from the previous 30 days
I have a dataset that uses dates, and I want to create two variables.我有一个使用日期的数据集,我想创建两个变量。 One is to flag where the 'created_date' is from the last 30 days, and another to flag where the 'created_date' is from the previous 30 days.
一个是标记“created_date”是过去 30 天的位置,另一个是标记“created_date”是前 30 天的位置。 The 30 days flag works fine, but the I'm having issues with the previous 30 days.
30 天标志工作正常,但我在前 30 天遇到问题。 Here is my code:
这是我的代码:
if created_date >= intnx("day","&sysdate"d,-30,"same") then Flag_30D = 1; else Flag_30D = 0;
if created_date <= intnx("day","&sysdate"d,-30,"same") and created_date >= ("day","&sysdate"d,-60,"same") then Flag_P30D = 1; else Flag_P30D = 0;
You have a typo and left out INTNX
in second part of if expression .您有一个错字并在 if表达式的第二部分中遗漏了
INTNX
。
The question/answer will likely be closed/deleted by a moderator.问题/答案可能会被版主关闭/删除。
created_date >= ("day","&sysdate"d,-60,"same")
should be应该
created_date >= INTNX("day","&sysdate"d,-60,"same")
^^^^^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.