BookmarkSubscribeRSS Feed
SharonZS
Obsidian | Level 7

Hi all,

I'm trying to create incremental count variables to identify the number of weeks and months since date of hire. I have dates of hire and termination and want to examine experiences during the first few weeks/months of employment. 

 

I've been trying to use INTCK to do this using an example from Ron Cody (he uses  a fixed date for first date and dResultdate is my variable for date of termination): 

week_num=INTCK('WEEK', '28APR2016'D, dResultDate ) + 1 ;
mos_num=INTCK('MONTH', '28APR2016'D, dResultDate ) + 1;

 

This gives me the ongoing count that I want for weeks and months since 04/28/16.

Is there a way to turn the fixed constant first date into a random variable for date of hire?  I keep getting a straight count constant for total number of weeks/months since hire. I'm using SAS v9.4.  I'll appreciate any suggestions anyone may have! Thank you!

3 REPLIES 3
Astounding
PROC Star

It's certainly possible to use a variable as the second parameter to INTCK:

 

week_num = intck('WEEK', HireDate, dResultDate) + 1;

 

However, a general note of caution when using INTCK ... it measures boundaries crossed, not number of days.  Make sure you understand the results from running these statements:

 

week_num = INTCK('WEEK', '31Aug2018'd, '02Sep2018'd) + 1;

month_num = INTCK('MONTH', '31Aug2018'd, '02Sep2018'd) + 1;

 

For that particular interval, the number of months is greater than the number of weeks.

PGStats
Opal | Level 21

There is a fourth argument to INTCK that shouldn't be left to its default value here. Experiment with:

 

week_num = INTCK('WEEK', hireDate, dResultDate, "CONTINUOUS");
month_num = INTCK('MONTH', hireDate, dResultDate, "CONTINUOUS");

It returns the number of full weeks (months) that have elapsed since hireDate.

 

PG
SharonZS
Obsidian | Level 7

Thank you both! Both solutions give me the continuous index that I'm looking for --- but first solution is strictly referenced with respect to the calendar (e.g. month 2 begins when next calendar month after month of hire begins rather than 4 weeks after hire date) rather than a straight count index of number of weeks/months worked since date of hire (solution #2).   Thank you for your help! 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 3 replies
  • 1037 views
  • 0 likes
  • 3 in conversation