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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1094 views
  • 3 likes
  • 2 in conversation