Hi,
I'm trying to compare the dates in two fields, and delete the row based on a condition. Here's what I have:
DATA PL.TREATMENT_PLANS_YEAR_365;
SET PL.TREATMENT_PLANS_YEAR;
current=date();
date365=intnx('day',date(),365);
if recalldate1>date365 then delete;
RUN;
recalldate 1 is in the format:
12OCT2012:00:00:00
date365 is in the SAS date format:
19466
How do I convert one or the other to make this comparison?
Thank you in advance
if datepart( recalldate1)>date365 then delete;
Haikuo
Update:
or if ' recalldate1' is character variable, then:
datepart(input( recalldate1 ,datetime20.)) >date365 then delete;
Haikuo
Thanks Hai.kuo. Would you know how to do this within a PROC SQL:
PROC SQL;
CREATE TABLE PX_RECALL_1 AS
SELECT * FROM
(SELECT SUM(UNITS) AS RECALL1_UNITS
FROM
PL.TREATMENT_PLANS_2012_04_11
WHERE RECALLTYPE='PX'
AND RECALLDATE1<=SYSDATE+365);
RUN;
It doesn't recognize sysdate.
ERROR: The following columns were not found in the contributing tables: SYSDATE.
if sysdate is a SAS table variable, then you don't have it.
If what you are trying to do is to extract the SAS session starting date, then use &sysdate,
if what you need is the today's date, then use today() or date()
Haikuo
Thank you Haikuo!
sysdate will be a date variable as will today() and date(), you'll still need to convert recalldate1 to a date format using datepart
ie
AND datepart(RECALLDATE1)<=(&SYSDATE+365)
Thanks Reeza!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.