Help using Base SAS procedures

checking dates in sql

Reply
Contributor
Posts: 74

checking dates in sql

I have a date variable where dates are stored as mmddyyyy format,
how do i check the date variable using sql where condition?
Suppose i want to select all records whre date is greater than 01012009
what will be sql for this.
Super Contributor
Super Contributor
Posts: 3,174

Re: checking dates in sql

Suggest you search the forum archives - a popular post/topic/question. Also, how about the SAS support http://support.sas.com/ website with a suitable search there as well?

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 61

Re: checking dates in sql

proc sql;
select *from dataset name
where date ge '01012009'd ;
quit;
SAS Super FREQ
Posts: 8,742

Re: checking dates in sql

Hi:
Please refer to the documentation on using constants in expressions:
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000780334.htm

Particularly, the use of date constants requires that the date constant be expressed in the form: ddMMMyy or ddMMMyyyy, as shown below:
[pre]
Use the following patterns to create date and time constants:

date='1jan2006'd;

date='01jan04'd;

[/pre]

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 116 views
  • 0 likes
  • 4 in conversation