I need help calculating the mean and sum of time entries so that the outputs is in HHMM and not numeric. SA
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
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.
Thanks! This worked.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.