DATA Step, Macro, Functions and more

enter sysdate in proc sql

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

enter sysdate in proc sql

Hi,

I want to check whether sales date is greater than current date or not. How can I do

I have written using oracle sqlra

select sales_date, sysdate from sales

where sales_date >sysdate

How to write in sas


Accepted Solutions
Solution
‎08-30-2012 10:03 AM
Super Contributor
Posts: 1,636

Re: enter sysdate in proc sql

You could use today():

proc sql;

  select sales_date format=mmddyy10.

    from sales

  where sales_date>today();

quit;

View solution in original post


All Replies
Solution
‎08-30-2012 10:03 AM
Super Contributor
Posts: 1,636

Re: enter sysdate in proc sql

You could use today():

proc sql;

  select sales_date format=mmddyy10.

    from sales

  where sales_date>today();

quit;

Contributor
Posts: 27

Re: enter sysdate in proc sql

Thanks linin for your great help

Super Contributor
Posts: 474

Re: enter sysdate in proc sql

Right.

Or use the system macro variable &SYSDATE9.

where sales_date > "&SYSDATE9"d;

which may return a different value from the TODAY() function, since it contains the date that the SAS job/session began executing.

TODAY function will return the actual date.

More on TODAY function here:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245961.htm

And SYSDATE9 here:

http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000489470.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt

Respected Advisor
Posts: 3,156

Re: enter sysdate in proc sql

Or date().

Haikuo

Super User
Posts: 5,498

Re: enter sysdate in proc sql

Just curious ... do we know for sure that SALES_DATE is actually a date rather than a datetime?  After all, this data appears to be coming from Oracle.

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 12576 views
  • 1 like
  • 5 in conversation