BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ralizadeh
Obsidian | Level 7

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)

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ralizadeh
Obsidian | Level 7

Never mind. I found why. I did not assign the prompt to the query.

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

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.

ralizadeh
Obsidian | Level 7

Never mind. I found why. I did not assign the prompt to the query.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 818 views
  • 0 likes
  • 2 in conversation