DATA Step, Macro, Functions and more

Comparing SAS Dates

Accepted Solution Solved
Reply
Contributor CEG
Contributor
Posts: 25
Accepted Solution

Comparing SAS Dates

Hello,

 

I'd like to compare dates by using TODAY and TODAY -1 to see when my incoming date (TODAY) becomes a new month.

 

Any suggestions?

 

Thanks,

CEG


Accepted Solutions
Solution
‎04-19-2017 02:01 PM
PROC Star
Posts: 283

Re: Comparing SAS Dates

[ Edited ]

Do you mean like:

 

if month(today()) ne month(today()-1);

 

or 

 

if month(today()) gt month(today()-1);

 

 

View solution in original post


All Replies
Solution
‎04-19-2017 02:01 PM
PROC Star
Posts: 283

Re: Comparing SAS Dates

[ Edited ]

Do you mean like:

 

if month(today()) ne month(today()-1);

 

or 

 

if month(today()) gt month(today()-1);

 

 

Contributor CEG
Contributor
Posts: 25

Re: Comparing SAS Dates

Posted in reply to novinosrin
Thanks.


Trusted Advisor
Posts: 1,934

Re: Comparing SAS Dates


CEG wrote:

Hello,

 

I'd like to compare dates by using TODAY and TODAY -1 to see when my incoming date (TODAY) becomes a new month.

 

Any suggestions?

 

Thanks,

CEG


You don't need to compare TODAY and TODAY-1 to see when a new month starts. You can just see if the day of the month is equal to 1. Which, in code, looks like:

 

if day(today)=1 then ... ;

Contributor CEG
Contributor
Posts: 25

Re: Comparing SAS Dates

Posted in reply to PaigeMiller
Thanks. I didn't know that.


☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 140 views
  • 2 likes
  • 3 in conversation