@InêsMaximiano wrote:
I need to use it for some filters. We need to do datepart(dateX) > yesterdaydate and datepart(dateX) <= dateY
When I do datepart(dateX) and get a SAS Date, so that's why I need all other dates to be also in the format of SAS Date.
Incorrect. SAS does all comparisons on unformatted values. Even if the date looks to you as 01JAN2025 (this is a formatted date), SAS still uses the unformatted date when it does arithmetic or comparisons.
Example:
data fakedata;
date='01JAN2025'd;
output;
date='26FEB2026'd;
output;
format date date9.;
run;
This code correctly finds the dates before yesterday
data _null_; /* UNFORMATTED DATE IN MACRO VARIABLE */
call symputx('yesterday',intnx('day',today(),-1));
run;
data want;
set fakedata;
if date<&yesterday;
run;
This code with a formatted date produces errors
data _null_; /* FORMATTED DATE IN MACRO VARIABLE */
call symputx('yesterday',put(intnx('day',today(),-1),date9.));
run;
data want;
set fakedata;
if date<&yesterday;
run;
... View more