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);
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');
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.