hi there
how to I define in my where clause to get yesterdays date?
For example in SQL it would be 'where DateBought = (getdate() - 1)'
what would be the getdate() equivalent in SAS?
The Today Function.
already tried that. doesnt work
Please elaborate on 'doesn't work'?
This gives you todays and yesterdays date.
data _null_;
today = today();
yesterday = today() - 1;
put today= date9. yesterday= date9.;
run;
I'm trying to do it in a proc sql;
Show your SQL Code please.
%LET START = TODAY(SYSDATE,'DD-MON-RR') -1;
proc sql;
create table Unsigned as
select *
from connection to odbc (
select
*
where
(DateDrafted = &START)
);
run;
So you are doing an explicit pass-through to MS SQL Server via ODBC.
This means that you need to use the SQL Server functions (and math) in the pass-through.
See here
(first result of a Google search for "ms sql server get yesterday's date", see Maxim 6)
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.