BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kathisas
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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?

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

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.

Astounding
PROC Star

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?

AravindanKarunakaran
Calcite | Level 5

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


 

Cerium23
Calcite | Level 5

How do you calculate days to months in SAS? I actually have days like 1575757. I need to convert this. Help. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 16101 views
  • 3 likes
  • 5 in conversation