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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 928 views
  • 0 likes
  • 2 in conversation