BookmarkSubscribeRSS Feed
karora1
Fluorite | Level 6

I'm trying to calculate the number of months between two dates but am have some trouble getting it right using the intck function. Essentially I'm trying to calculate the age of the client when they have had an immunisation. In this case the actual month interval needs to have passed in order for the month to occur. For example a client born Feb 13, 2015 would only be 26 months old if they received the immunisation on May 1, 2017.  In order for them to be 27 months they would have to have received the immunisation on May 13 or later. However using the intck formula listed below will calculate them to be 27 months. I believe this is because it has started the next interval (ie. May has started). I'm not sure how to adjust the formula so that it calculates it the way i would like (e.g. can i somehow add and if statement to -1 if the day in date of of admin is < day in the date of birth). Any thoughts welcome.

/*AGE AT ADM*/
age_at_adm = intck('month',DATE_OF_BIRTH,DATE_ADMINISTERED);
2 REPLIES 2
Reeza
Super User
Look at the fourth parameter of the INTCK function and try some of the different settings to see if you get what you want.
karora1
Fluorite | Level 6

That was the answer. i didn't realise there were fourth parameters in the intck, i though it was only for the intnx function that had the 4th options. Anyway if you adjust the code to be the following (C is for continuous) then I get what i want. 

/*AGE AT ADM*/
age_at_adm = intck('month',DATE_OF_BIRTH,DATE_ADMINISTERED,'C');

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 1332 views
  • 3 likes
  • 2 in conversation