BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Caro17
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

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.

 

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19

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.

 

PeterClemmensen
Tourmaline | Level 20
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;
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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