Hi,
I have to compare surgery date and lab date
surgery date stays same whereas lab_date changes and the dates are datetimes
we have to check if lab date is +/- 2 weeks from surgery date and keep only those and discard others
Surgery date lab_date
28jun2011:9:30 09jul2011:10:00----------keep
28jun2011:9:30 16jul2011:12:00---------discard(lab date more than 2 weeks from surg date)
28jun2011:9:30 08jul2011:09:00-------keep
Thanks
please try,
data have;
input date1 : datetime18. date2 : datetime18.;
format date1 date2 datetime18.;
if (datepart(date2)-datepart(date1))/7 >2 then delete;
cards;
28jun2011:9:30 09jul2011:10:00
28jun2011:9:30 16jul2011:12:00
28jun2011:9:30 08jul2011:09:00
;
run;
Thanks,
jagadish
Hi Jagadish,
But here you're not consider time part.I think you should time part also.
Regards,
Ramesh
I probably would use intck() instead of an expression like "(datepart(date2)-datepart(date1))/7 >2"
when i try to use intck function, the result in week is a integer value. so we are unable to check if the week is 2 or more than 2. as per the data provided the second record is more than 2 weeks, however with intck it is 2.
data have;
input date1 : datetime18. date2 : datetime18.;
format date1 date2 datetime18.;
value1=(datepart(date2)-datepart(date1))/7;
value=intck('week', datepart(date1), datepart(date2));
cards;
28jun2011:9:30 09jul2011:10:00
28jun2011:9:30 16jul2011:12:00
28jun2011:9:30 08jul2011:09:00
;
run;
Please check the difference between value1 and value variables. is there any way to avoid it with intck. please suggest.
With datetime values I would use the datetime intervals with intck().
if intck('dtday', date1, date2) > 13 then delete;
Thanks Patrick , indeed a good way
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.