BookmarkSubscribeRSS Feed
harshronaldo
Calcite | Level 5

Hi ,

 

i am not able to calculate mean of time which is in a format of HHMM.? when i am using proc mean it giving me  the output in numeric value but i wanted the output only HHMM. format only .

3 REPLIES 3
ballardw
Super User

Proc mean statistics do not inherit the formats of the base variables. So either send the output to a data set and assign the desired format or use a different reporting procedure that allows specifying the format in the displayed output such as Proc Tabulate or Proc Report

art297
Opal | Level 21

Use proc template to have proc means output the means using the time5. format. e.g.:

data have;
  input time time5.;
  cards;
9:30
10:30
11:30
;

ods path(prepend) work.templat(update);
proc template;
 edit base.summary;
  edit mean;
   format=time5.;
  end;
 end;
run;
 
proc means data=have mean;
  var time;
run;
 
/* restore default template */
proc template;
 delete base.summary;
run;

Art, CEO, AnalystFinder.com

 

ballardw
Super User

@art297 wrote:

Use proc template to have proc means output the means using the time5. format. e.g.:

Art, CEO, AnalystFinder.com

 


@art297 We'll hope the OP wasn't requesting statistics for any other variables with the template approach. Though I do find the idea of a mean height of 0:02:45 cm very entertaining...

Using that template:

 

proc means data=sashelp.cars mean;
  var msrp horsepower ;
run;

The MEANS Procedure

Variable       Mean

MSRP           9:06
Horsepower     0:03

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2022 views
  • 2 likes
  • 3 in conversation