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)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.