I want to write a CASE WHEN statement. I would like to use my prompt date that has an start date and end date. SAS EG will code it as "&DateRange_min"d and "&DateRange_max"d. No need to think about the end date for this question.
I want to choose those rows in my table that their dates are between "&DateRange_min"d and 12 month later.
For example if "&DateRange_min"d is 11/01/2021 then "&DateRange_min"d + 12 months should come out as 10/31/2022 (last day of that month). I need any rows between these two dates (which easily can be done with CASE WHEN statement if I could figure out the end date). I need to make sure the codes would work properly when the interval crosses the year boundary e.g. "&DateRange_min"d is in 2021, and 12 month later is another year e.g. 2022 while also taking into consideration that not all months have the same number of days in them.
I wrote the code below to first create a computed column in Query Builder that will add 12 months to "&DateRange_min"d, however I get an error. Any thought, why?
intnx(month, &DateRange_min, 12, e)
This is also failed
intnx(month, "&DateRange_min"d, 12, e)
Never mind. I found why. I did not assign the prompt to the query.
If you want an opinion as to why an error has happened then you really need to post the error and the code causing it from your SAS log.
Never mind. I found why. I did not assign the prompt to the query.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.