## calculate days in month

Solved
Occasional Contributor
Posts: 9

# calculate days in month

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

Accepted Solutions
Solution
‎03-13-2017 01:45 PM
Super User
Posts: 6,751

## Re: calculate days in month

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?

All Replies
Posts: 1,837

## Re: calculate days in month

[ Edited ]

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.

Solution
‎03-13-2017 01:45 PM
Super User
Posts: 6,751

## Re: calculate days in month

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?

Learner
Posts: 1

## Re: calculate days in month

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
• 3 replies
• 1627 views
• 3 likes
• 4 in conversation