BookmarkSubscribeRSS Feed
lloraine
Calcite | Level 5
I am so new to SAS that I am not sure how to even ask a question but here goes - I want to say the following in a Where statement:

Eff_Frm_Dt GE to TODAY. How do I use functions in a Where statement?
3 REPLIES 3
Olivier
Pyrite | Level 9
Juste add a pair of parenthesis to TODAY, so as it is known as a function.
[pre]
Eff_Frm_Dt >= TODAY()
[/pre]

Regards.
Olivier
JasonDiVirgilio
Quartz | Level 8
...or if your eff_frm_dt returns a datetime value you could do:

Eff_Frm_Dt >= datetime()

or:

eff_frm_dt >= dhms(date(),00,00,00)

This is assuming that you are not connecting to a database. If you are, you'll have to format the output of the SAS date function to match whatever format the database returns a date value.
Doc_Duke
Rhodochrosite | Level 12
Linda,

There are some types of functions that work in different ways in SQL from the data step (they are called "aggregate" functions, like mean, sum, etc.). For those, look at the SQL reference manual.

Your question is sufficiently naive that you may want to do some background reading. There are (at least) two Books-By-Users that are available on the SAS/Publishing web site that address SAS and SQL. Prairie's might be a good place to start, followed by Lafler's book.

For your specific example, the SQL might look something like

PROC SQL;
CREATE TABLE xyz AS
SELECT
*
FROM mydata.abc
WHERE
Eff_Frm_Dt GE TODAY()
;
QUIT; RUN;

as the result-equivalent of

DATA xyz;
SET mydata.abc;
IF Eff_Frm_Dt GE TODAY();
RUN;

Doc Muhlbaier
Duke

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!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 3 replies
  • 993 views
  • 0 likes
  • 4 in conversation