Desktop productivity for business analysts and programmers

Bring records between two dates

Reply
N/A
Posts: 0

Bring records between two dates

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
SAS Super FREQ
Posts: 8,721

Re: Bring records between two dates

Hi:
The simple answer is that you need to use the right method for referencing the date:
[pre]
where current_hire_date between "01Sep2006"d and "31Aug2007"d;
[/pre]
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.

In addition, this forum posting
http://support.sas.com/forums/thread.jspa?messageID=6844᪼
contains a list of prior forum postings about how SAS handles dates. 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
Ask a Question
Discussion stats
  • 1 reply
  • 8326 views
  • 0 likes
  • 2 in conversation