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

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 562 views
  • 1 like
  • 3 in conversation