Is my interpretation correct
if first date is 20th.could someone explain to me with example
/*date is WITHIN 5 days prior to the first_date*/
if date ge (first_date - 60*60*24*5)
/*date is WITHIN 5 days post to the first_date*/
if date le (first_date + 60*60*24*5) ;
If first_date is a datetime field, the comparisons are just adding or subtracting the number of seconds elapsed before or after a given date. However, neither is accounting for WITHIN a given time period as such a comparison would require three dates to be compared.
first_date is a datetime field. and date is also date time field
i have two datetimess: date and first_date
i want to see if date is within +/- 5 days of first_date
and the below is for +5 or -5????
if date ge (first_date - 60*60*24*5)
Is time a factor for these date time comparisons?
no
Robert,
Be careful how you answer Fareeza'a question. It isn't a factor if your times are all zero but, if they do represent actual times, you could be misclassifying the differences. The following does consider time to be relevant:
data have;
informat date first_date datetime21.;
format date first_date datetime21.;
informat test_date date9.;
format test_date date9.;
input test_date span;
first_date=dhms(test_date,0,0,0);
date=dhms(test_date+span,0,0,0);
/*date is WITHIN 5 days prior to the first_date*/
prior=-5*60*60*24 le date-first_date le 0;
/*date is WITHIN 5 days post to the first_date*/
post=0 le date-first_date le 5*60*60*24;
cards;
03DEC2013 4
03DEC2013 6
03DEC2013 -4
03DEC2013 -6
;
If time really isn't relevant, and aren't all represented with zeros, than I'd suggest changing the formulas to compare the dateparts of the two fields and not adjusted for seconds.
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.