hey 🙂
pleas help me.
I have to calculate an observation time between two dates and sas calculates the days of the periode. How can I get sas to calculate it in months?
thank you for your help
A simple approach would transform the number of days into number of months:
n_months = (date2 - date1) / 30.5;
Do you have different rules in mind for computing number of months?
Assuming you have sas numeric dates then you can use:
period = intck('month',date2,date1);
If your data containd datetime variables you should use datepart() function
to convert datetime into sas date.
A simple approach would transform the number of days into number of months:
n_months = (date2 - date1) / 30.5;
Do you have different rules in mind for computing number of months?
dur_month = dur_day/30.4375;
365.25 days per year.
365 days in normal year
366 days in Leap year
0.25 days * 4 year becomes extra day in Leap year
so, 365.25/12 = 30.4375 days per month
@kathisas wrote:hey 🙂
pleas help me.
I have to calculate an observation time between two dates and sas calculates the days of the periode. How can I get sas to calculate it in months?
thank you for your help
How do you calculate days to months in SAS? I actually have days like 1575757. I need to convert this. Help.
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.