BookmarkSubscribeRSS Feed
ursula
Pyrite | Level 9

I tried to do a math of the Elapstime, for example: Time_pickup =15:00 and Time_received=15:36, so the Elapstime will be Time_received - Time_pickup.

the result is not showing the time value, like 0:36 instead 2160.

does any one know what is the 'Time Format' is?

thank you.

7 REPLIES 7
AncaTilea
Pyrite | Level 9

Try this:

   format Elapstime time5.;

Good luck.

Anca.

ursula
Pyrite | Level 9

thank you so much, Anca, it's very helpful.

ursula
Pyrite | Level 9

Another problem is, when I got the Elapsed_time fixed, but, when I run it in proc means, it came back as a long number again instead of like 0:35.

Do you know how to fix it?

thanks,

Linlin
Lapis Lazuli | Level 10

data have;

input time;

cards;

2160

2161

2162

2163

;

proc means data=have mean noprint;

var time;

format time time5.;

output out=temp(drop=_:) mean=mean;

run;

proc print data=temp;run;

                                Obs     mean

                                    1      0:36

ursula
Pyrite | Level 9

thank you very much.

do you mind to explain to me what is the "output out=temp(drop=_:) mean= mean" means?

thank you.

Linlin
Lapis Lazuli | Level 10

You are welcome!

"output out="  creates a dataset," (drop=_:)" drop all the variables begin with _. "mean=mean" names the calculated mean mean.

you may understand better by running the modified code below:

data have;

input time;

cards;

2160

2161

2162

3863

;

proc means data=have mean noprint;

var time;

format time time5.;

output out=new_dataset /* temp(drop=_:)*/ mean=aaa /*mean*/;

run;

proc print data=new_dataset;run;

                       Obs    _TYPE_    _FREQ_      aaa

                          1          0              4           0:43

ursula
Pyrite | Level 9

Thank you again, Have a great weekend!

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2071 views
  • 9 likes
  • 3 in conversation