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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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