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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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