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

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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

 

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

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.

 

--
Paige Miller

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 608 views
  • 0 likes
  • 2 in conversation