Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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. 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;

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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")
                ^^^^
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading