BookmarkSubscribeRSS Feed
samenumey
Calcite | Level 5

I need help calculating the mean and sum of time entries so that the outputs is in HHMM and not numeric. SA

3 REPLIES 3
mkeintz
PROC Star

You know that movie ("Jerry Maguire") where a famous statement is "show me the money!"?

 

Show us the data.  Help us to help you.

 

data have;
  input tim  time8.0:
  format tim time8.0;
datalines;
10:50:49
15:20:45
run;

data in the form of a sas data step to get extra credit, as in

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ballardw
Super User

Without numeric values "mean" and "sum" are kind of meaningless in many contexts.

If you have SAS time values then you can use any of a number of procs to create the values. To assign a specific display format might require another step.

 

If this were my data I would start with something like

 

Proc summary data=have;

   var timevariable;

   output out=want   sum=timesum mean=timemean;

run;

 

proc print data=want;

   var timesum timemean;

   format timesum timemean hhmm8.;

run;

 

The width of HHMM format would depend somewhat on the expected range of values, you could go to 20, if you want to show fractions of a minute include the number of decimals you want displayed such as hhmm10.2 would use 10 characters for display with 2 decimal places.

 

The FORMAT is how a value displays, the values are numeric.

 

samenumey
Calcite | Level 5

Thanks! This worked.

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
  • 3 replies
  • 1614 views
  • 0 likes
  • 3 in conversation