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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

  if datepart( recalldate1)>date365 then delete;

Haikuo

View solution in original post

7 REPLIES 7
Haikuo
Onyx | Level 15

  if datepart( recalldate1)>date365 then delete;

Haikuo

Haikuo
Onyx | Level 15

Update:

or if ' recalldate1' is character variable, then:

datepart(input( recalldate1 ,datetime20.)) >date365 then delete;

Haikuo

teg_76
Calcite | Level 5

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.

Haikuo
Onyx | Level 15

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

teg_76
Calcite | Level 5

Thank you Haikuo!

Reeza
Super User

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)

teg_76
Calcite | Level 5

Thanks Reeza!

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!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1441 views
  • 0 likes
  • 3 in conversation