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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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