hi there,
I am trying to calculate age as the number of total months as of a specific date. But I am getting the number of years. Please help me to fix this issue?
DATA AGE_MONTHS; SET TEST; TODAY = MDY(03,31,2021); DAYS = TODAY - Launch_Date; AGE=FLOOR((INTCK('month',Launch_Date,TODAY) - (DAY(TODAY) < DAY(Launch_Date))) / 12); RUN;
regards,
sara
You are already using the INTCK Function and specifying "MONTH" as the interval so why divide by 12?
You are already using the INTCK Function and specifying "MONTH" as the interval so why divide by 12?
THANKS HEAPS.
You may want to consider use of the INTCK method option='C' such as
INTCK('month',Launch_Date,TODAY,'C')
The default of 'D' or discrete may not yield quite what you want.
Consider this example:
data example; date1 = '18Mar2021'd; date2 = '02Jul2021'd; default = intck('month',date1,date2); cont = intck('month',date1,date2,'C'); run;
Decide what you would expect to be the number of months between those two dates (think perhaps of date1 as a date of birth and the other the date of some service). Then run the code and pick the appropriate version.
I used two close together dates intentionally so you can decide before running the code.
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.