BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dash
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

You could use today():

proc sql;

  select sales_date format=mmddyy10.

    from sales

  where sales_date>today();

quit;

View solution in original post

5 REPLIES 5
Linlin
Lapis Lazuli | Level 10

You could use today():

proc sql;

  select sales_date format=mmddyy10.

    from sales

  where sales_date>today();

quit;

dash
Obsidian | Level 7

Thanks linin for your great help

DanielSantos
Barite | Level 11

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

Haikuo
Onyx | Level 15

Or date().

Haikuo

Astounding
PROC Star

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 28701 views
  • 1 like
  • 5 in conversation