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

Hello everyone,

 

I have a table where i want to keep only three years of data.

what i want to do is to delete from the table where (DT_OPER : keep three years).

DT_OPER is of type date like 2019/10/01.

can you help please.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Do something like this

 

data want;
    set have;
    where DT_OPER >= intnx('year', today(), -3, 's');
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Do something like this

 

data want;
    set have;
    where DT_OPER >= intnx('year', today(), -3, 's');
run;
PGStats
Opal | Level 21

Also, to run an analysis only on those three years you don't need to create a new dataset. You can simply use a WHERE statement when running the procedure. For example:

 

proc means data=have;
where year(DT_OPER) in (2010, 2011, 2012);
var myVar;
....
run;
PG