BookmarkSubscribeRSS Feed
leam3
Calcite | Level 5

I am trying to figure out if a new procedure change implemented between year 1 and year 2 has caused a delay in the procedure being administered. I have a procedure start time and procedure end time which are both time. formatted, and subtracted the difference to create a variable = duration between start and finish times (which is also formatted as a time).

 

I would like to find the average of these durations, but proc means does not maintain the time format. I have searched several threads and tried many of their suggestions but have not yet found a solution.

 

I have tried doing an output= option with proc means, but I'm not sure this is exactly what I need because ideally I would like to be able to calculate different averages of duration based on other different variables/strata in addition to year.

 

Thanks for your help!

2 REPLIES 2
Astounding
PROC Star
You have started out correctly. But PROC MEANS does not let you format statistics in the output data set. The simplest solution is to add a step to apply a TIME format, just as you did with your calculated durations. If your data set is huge, we can explore ways that are faster yet more complex.
ballardw
Super User

@leam3 wrote:

I am trying to figure out if a new procedure change implemented between year 1 and year 2 has caused a delay in the procedure being administered. I have a procedure start time and procedure end time which are both time. formatted, and subtracted the difference to create a variable = duration between start and finish times (which is also formatted as a time).

 

I would like to find the average of these durations, but proc means does not maintain the time format. I have searched several threads and tried many of their suggestions but have not yet found a solution.

 

I have tried doing an output= option with proc means, but I'm not sure this is exactly what I need because ideally I would like to be able to calculate different averages of duration based on other different variables/strata in addition to year.

 

Thanks for your help!


Proc Means, and its cousin Proc Summary, will allow you do get summaries by multiple strata with a single pass through  the data.

Place all of the strata variables, including year, in a CLASS statement.

The output data set, which you will want, will have a variable _type_ that indicates the combination of strata variables involved for any summary row. _TYPE_=0 is overall, i.e. not stratified and _TYPE_ = 2**n - 1, where n= number of class variables, it the combination of all of the strata. By selecting the correct _type_ you can examine any desired combination.

 

Assign the appropriate format to the statistics in a following data step or Report procedure syntax.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 940 views
  • 0 likes
  • 3 in conversation