BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
RandyStan
Fluorite | Level 6

Dear All:

 

Here is the code I wrote:

 

Data want ; set have;

if Year < 2015 then VarA = INTCK ('Minute25.' , '10:00:00't , time); else

if year >= 2015 then VarA = INTCK ('Minute25.' , '09:15:00't, time) ;

run;

I cannot get the 25 minute intervals starting at different times for the different years.   What mistake am I making?

 Randy

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @RandyStan,

 

I think for year >= 2015 you want to count 25-minute intervals starting at '09:15:00't, i.e., the first interval ends at '09:39:59't. For this you need to request the continuous method in the fourth argument of the INTCK function:

if year >= 2015 then VarA = INTCK ('Minute25', '09:15:00't, time, 'c');

 

With the default discrete method the first interval boundary after '09:15:00't is between '09:34:59't and '09:35:00't = 23*'0:25:00't (integer multiple of the interval starting at '0:00:00't). You don't have this problem for the other years because '10:00:00't (unlike '09:15:00't) happens to be an integer multiple of '0:25:00't'10:00:00't = 24*'0:25:00't. So in that case the discrete and the continuous method yield the same results. For consistency and clarity you could specify the 'c' argument in both cases.

 

Edit:

Example: The number of 25-minute intervals from 9:15 through 10:28 is ...

  • 3    = intck('minute25','09:15't,'10:28't) by the discrete method (counting the 0:00-based interval boundaries at 9:35, 10:00 and 10:25)
  • 2    = intck('minute25','09:15't,'10:28't,'c') by the continuous method (counting the 9:15-based interval boundaries at 9:40 and 10:05)
  • 2.92 = ('10:28't-'09:15't)/'0:25't by measuring the time difference in units of 25 minutes rather than counting interval boundaries.

View solution in original post

4 REPLIES 4
MarkusWeick
Barite | Level 11

Hi @RandyStan,

does it work for the years < 2015?

Best

Markus

Please help to keep the community friendly.
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
FreelanceReinh
Jade | Level 19

Hello @RandyStan,

 

I think for year >= 2015 you want to count 25-minute intervals starting at '09:15:00't, i.e., the first interval ends at '09:39:59't. For this you need to request the continuous method in the fourth argument of the INTCK function:

if year >= 2015 then VarA = INTCK ('Minute25', '09:15:00't, time, 'c');

 

With the default discrete method the first interval boundary after '09:15:00't is between '09:34:59't and '09:35:00't = 23*'0:25:00't (integer multiple of the interval starting at '0:00:00't). You don't have this problem for the other years because '10:00:00't (unlike '09:15:00't) happens to be an integer multiple of '0:25:00't'10:00:00't = 24*'0:25:00't. So in that case the discrete and the continuous method yield the same results. For consistency and clarity you could specify the 'c' argument in both cases.

 

Edit:

Example: The number of 25-minute intervals from 9:15 through 10:28 is ...

  • 3    = intck('minute25','09:15't,'10:28't) by the discrete method (counting the 0:00-based interval boundaries at 9:35, 10:00 and 10:25)
  • 2    = intck('minute25','09:15't,'10:28't,'c') by the continuous method (counting the 9:15-based interval boundaries at 9:40 and 10:05)
  • 2.92 = ('10:28't-'09:15't)/'0:25't by measuring the time difference in units of 25 minutes rather than counting interval boundaries.
RandyStan
Fluorite | Level 6

Thanks much

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 717 views
  • 5 likes
  • 4 in conversation