Dear Guru's,
I am struck up with the logic in maintaining the DB2 table with only 30 days data.
In detail :
I will load the DB2 table through SAS Job daily. So, once the 31st day date is loaded then the first day data should be deleted or archived like FIFO( 30days).
so every time I should maintain only 30 days data.
How can I do that. Can some one please help with user written code.
Appreciate your inputs
Thanks,
Vicks
Without any data, I can only give you an abstract:
where date > today() - 30;
Thanks Kurt,
Yes that works, but I am loading daily data into my DB2 table and I am looking to update this table every day so, that the more than 30 days records gets deleted.
Thanks,
Vicks
@vickys wrote:
Thanks Kurt,
Yes that works, but I am loading daily data into my DB2 table and I am looking to update this table every day so, that the more than 30 days records gets deleted.
Thanks,
Vicks
That's exactly what the where condition does, it only keeps observations younger than 30 days. Apply it to your existing dataset:
data new;
set
old (where=(date > today() - 30))
import
;
run;
Ups, yeah, the OP is talking about an operation within DB/2. With DB/2 (or any DBMS), one can selectively delete the older observations, as that will really free the spaces (what you don't get with SAS, where space is freed only with a complete rewrite).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.