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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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