Hello Everyone! Hope you all are doing great!
I got some time variables in the hh:mm:ss format and i need to get the mean of them:
04:47:32 | 02:26:01 | 02:22:59 | 02:33:03 | 01:57:31 |
04:40:54 | 03:27:40 | 01:43:49 | 02:46:13 | 01:20:01 |
04:36:07 | 03:36:04 | 01:28:21 | 02:27:37 | 01:18:16 |
04:07:07 | 03:55:09 | 01:51:59 | 02:21:11 | 01:05:33 |
03:55:44 | 04:38:44 | 01:17:46 | 02:16:04 | 00:57:53 |
03:59:19 | 05:00:16 | 01:13:54 | 02:39:59 | 00:59:44 |
I need to get the mean by colunm, so for example, i want SAS to read
04:47:32 |
04:40:54 |
04:36:07 |
04:07:07 |
03:55:44 |
03:59:19 |
add up the time in the colunm (26:06:43) and divide it by the number of lines (6). How to i program this?
Thanks in advance!
First, these have to be numeric time values, not character strings or numeric dates or anything else. Assuming that's what they are, PROC MEANS/PROC SUMMARY will compute the means for you.
proc summary data=have;
var column1-column5;
output out=want mean=;
run;
First, these have to be numeric time values, not character strings or numeric dates or anything else. Assuming that's what they are, PROC MEANS/PROC SUMMARY will compute the means for you.
proc summary data=have;
var column1-column5;
output out=want mean=;
run;
Hey PaigeMiller! Thanks for the help!
Sorry if the question was to basic.
Here the final output if anyone needs an example:
DATA have;
infile cards dlm='09'x dsd truncover;
input (column1 column2 column3 column4 column5) (:time.);
format column1--column5 time8.;
CARDS;
04:47:32 02:26:01 02:22:59 02:33:03 01:57:31
04:40:54 03:27:40 01:43:49 02:46:13 01:20:01
04:36:07 03:36:04 01:28:21 02:27:37 01:18:16
04:07:07 03:55:09 01:51:59 02:21:11 01:05:33
03:55:44 04:38:44 01:17:46 02:16:04 00:57:53
03:59:19 05:00:16 01:13:54 02:39:59 00:59:44
run;
proc summary data=have;
var column1-column5;
output out=want mean=;
run;
Thanks again, PaigeMiller!
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.
Ready to level-up your skills? Choose your own adventure.