hello,
i need to calculate this within a proc sql querym i've tried a number of things to get it right. i see the problem, since when i do datepart(sampledate) it returns an integer, but datepart(filedate) returns 0 so the intck calculation is way off. how do i get datetime and date9 to play well together in the query?
filedate = 07JUN1997 (date9.)
sampledate = 30AUG2021:08:00:00.0000000 (datetime26.7)
proc sql; create table work.result as select intck('dtday',sampledate,filedate) from table
Both variables have to be the same units ... in one case, the variable that is DATE9. is measured internally in units of days; the variable that is DATETIME26.7 is measured in units of seconds.
You have to convert the DATETIME26.7 variable to days, or alternatively convert the DATE9. variable to seconds, and then you can do this.
Example:
intck('day',datepart(sampledate),filedate)
The datepart function converts datetime values measured in seconds to date values measured in days, and then the arithmetic works.
Both variables have to be the same units ... in one case, the variable that is DATE9. is measured internally in units of days; the variable that is DATETIME26.7 is measured in units of seconds.
You have to convert the DATETIME26.7 variable to days, or alternatively convert the DATE9. variable to seconds, and then you can do this.
Example:
intck('day',datepart(sampledate),filedate)
The datepart function converts datetime values measured in seconds to date values measured in days, and then the arithmetic works.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.