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!! 🙂

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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