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

Hi 

 

I have two date columns namely accept_date and issue_date.

Both are numeric and in format 08MAR2008.

 

I need to find average between accept_date and issue_date.

 

Thanks in advance.

Vishyy

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

One possibility:

 

data want;

set have;

days_between = issue_date - accept_date;   /* may need to reverse this */

run;

 

proc means data=want;

var days_between;

run;

 

Part of the answer depends on what you mean when you say "find" the average.  This program gives you a report with the average.

View solution in original post

5 REPLIES 5
ballardw
Super User

You may want to clarify this a bit. The average is likely to have a fractional component. How do you want that treated?

Example:

data _null_;
   meandate = mean('01FEB2017'd,'02FEB2017'd);
   put meandate  meandate= date9. ;
run;

In terms of a format the date would get rounded.

 

So do you want an integer date value for the mean or what?

vishyy
Obsidian | Level 7

I need the difference between these two dates and then the average.

ballardw
Super User

average can be done with the mean function as in my previous example. Just put your variables in place of the values.

Difference may require more information. Is one date always after the other and you want the later minus the earlier? Of is there more of a rule involved.

 

difference = accept_date - issue_date;

 

is one way.

Reeza
Super User

1. Find the difference for every record.

2. Compute the average the distance variable created from step 1. 

 

You haven't provided any data so we can't say how this should be coded. There have been some suggestions but they're based on experience and guesses at this point. 

Astounding
PROC Star

One possibility:

 

data want;

set have;

days_between = issue_date - accept_date;   /* may need to reverse this */

run;

 

proc means data=want;

var days_between;

run;

 

Part of the answer depends on what you mean when you say "find" the average.  This program gives you a report with the average.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 3008 views
  • 1 like
  • 4 in conversation