BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
I would like to retrieve records in Proc sql , employees hired between two dates. How can I enter two dates in where clause in proc sql?
I get error if I use the follwing statement
WHERE CURRENT_HIRE_DATE GE 01Sep2006 AND
CURRENT_HIRE_DATE LE 31Aug2007.


Please give your suggestions

Thanks,
Vanitha
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:
The simple answer is that you need to use the right method for referencing the date:

where current_hire_date between "01Sep2006"d and "31Aug2007"d;


The d after the date is called a date constant. You can look up how the date constant, the datetime constant and other constants work in the SAS online documentation or help files.

The above code makes the assumption that CURRENT_HIRE_DATE contains a DATE value (number of days since Jan 1, 1960) and NOT a DATE/TIME value. For more help with these concepts or for quick resolution of your code issues, you might consider contacting Tech Support.

cynthia

View solution in original post

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:
The simple answer is that you need to use the right method for referencing the date:

where current_hire_date between "01Sep2006"d and "31Aug2007"d;


The d after the date is called a date constant. You can look up how the date constant, the datetime constant and other constants work in the SAS online documentation or help files.

The above code makes the assumption that CURRENT_HIRE_DATE contains a DATE value (number of days since Jan 1, 1960) and NOT a DATE/TIME value. For more help with these concepts or for quick resolution of your code issues, you might consider contacting Tech Support.

cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1 reply
  • 34100 views
  • 0 likes
  • 2 in conversation