BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
amyk
Fluorite | Level 6

I am trying to set a filter using  dates: 

if build_mn  < sold_mn - 3 then do ;
...

...

end ;

 

It is grabbing all the records and not filtering. I think I am using the sold_mn - 3 wrong. 

 

Can someone help me with this?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Assuming you have SAS date variables, numeric with a date format, you can use the INTNX() function to increment a date. Look at the fourth parameter that will increment a date to either the same day of the month, end or beginning so that your comparison is what you want.

Something along these lines, you'll need to set the parameters for what you need:

build_mn < intnx('month', build_mn, 4, 'e')

View solution in original post

4 REPLIES 4
Reeza
Super User

@amyk wrote:

I am trying to set a filter using  dates: 

if build_mn  < sold_mn - 3 then do ;
...

...

end ;

 

It is grabbing all the records and not filtering. I think I am using the sold_mn - 3 wrong. 

 

Can someone help me with this?


What are you trying to do? You've shown non working code, but not explained what you think it's doing or what you want it to do.

amyk
Fluorite | Level 6

I want to set a flag if the build month is 4 months less then the sold month then set flags. 

Reeza
Super User
Assuming you have SAS date variables, numeric with a date format, you can use the INTNX() function to increment a date. Look at the fourth parameter that will increment a date to either the same day of the month, end or beginning so that your comparison is what you want.

Something along these lines, you'll need to set the parameters for what you need:

build_mn < intnx('month', build_mn, 4, 'e')
amyk
Fluorite | Level 6

Thanks that helped. 

I ended up using it as follows:

 

build_mn le intnx('month', build_mn, -4, 'e')

 

It gave me exactly what I was looking for. Again thank you so much!! 🙂

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 859 views
  • 2 likes
  • 2 in conversation