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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 508 views
  • 1 like
  • 3 in conversation