Home > OS >  Flag rows in a SAS table dated from the previous 30 days
Flag rows in a SAS table dated from the previous 30 days

Time:06-29

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. The 30 days flag works fine, but the I'm having issues with the previous 30 days. 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;

CodePudding user response:

You have a typo and left out INTX in second part of if expression.

The question/answer will likely be closed/deleted by a moderator.

created_date >= ("day","&sysdate"d,-60,"same")

should be

created_date >= INTX("day","&sysdate"d,-60,"same")
                ^^^^
  • Related