Hey,
I just want to do an inquiry and skip e. g. 30 days always from today. For example, today is 21 July 2020 and I don't want to have the data from 21 June 2020 till 21 July 2020 but all the other data. How can I do this?
In SQL I used trunc and sysdate, e. g. date <= trunc(sysdate-30). Can I use this in SAS as well?
I am using SAS Enterprise Guide Version 7.15 HF2.
Thanx in advanced!
Best regards
Caro
What to do depends, as always, on the data you have. If you have a sas-date, you can do something like
date <= today()-30
If you have a datetime-variable, then
datepart(date) <= today()-30
should do it.
What to do depends, as always, on the data you have. If you have a sas-date, you can do something like
date <= today()-30
If you have a datetime-variable, then
datepart(date) <= today()-30
should do it.
data have;
do date = '01jan2020'd to '31dec2020'd;
output;
end;
format date ddmmyy10.;
run;
data want;
set have;
where date < intnx('day', today(), -30) | date > today();
run;
Do you want to skip thirty days, or a month? If it's a month, use the INTNX() function in your WHERE condition.
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 lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.