Comparing Dates

Accepted Solution Solved
Reply
Super Contributor
Posts: 494
Accepted Solution

Comparing Dates

[ Edited ]

I’m trying to only include observations that are current.

 

proc print data=employee (obs=10);

            where position_begin_date <= date();

run;

 

Position_begin_date is of type datetime and includes rows where the condition is true.  However no observations are returned.  Am I missing something on SAS date comparisons?

.


Accepted Solutions
Solution
‎05-11-2016 09:23 AM
Trusted Advisor
Posts: 1,116

Re: Comparing Dates

[ Edited ]

Hi @DavidPhillips2,

 

You are comparing datetimes with dates. Try this:

where . < position_begin_date <= datetime();

Edit: Inserted the condition . < ... assuming that you don't want to include observations with missing values of position_begin_date.

View solution in original post


All Replies
Solution
‎05-11-2016 09:23 AM
Trusted Advisor
Posts: 1,116

Re: Comparing Dates

[ Edited ]

Hi @DavidPhillips2,

 

You are comparing datetimes with dates. Try this:

where . < position_begin_date <= datetime();

Edit: Inserted the condition . < ... assuming that you don't want to include observations with missing values of position_begin_date.

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 233 views
  • 0 likes
  • 2 in conversation