Help using Base SAS procedures

How to do the format Time value

Reply
Contributor
Posts: 64

How to do the format Time value

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.

Super Contributor
Posts: 543

Re: How to do the format Time value

Try this:

   format Elapstime time5.;

Good luck.

Anca.

Contributor
Posts: 64

Re: How to do the format Time value

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

Contributor
Posts: 64

Re: How to do the format Time value

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,

Super Contributor
Posts: 1,636

Re: How to do the format Time value

data have;

input time;

cards;

2160

2161

2162

2163

;

proc means data=have mean noprint;

var time;

format time time5.;

output out=temp(drop=_Smiley Happy mean=mean;

run;

proc print data=temp;run;

                                Obs     mean

                                    1      0:36

Contributor
Posts: 64

Re: How to do the format Time value

thank you very much.

do you mind to explain to me what is the "output out=temp(drop=_Smiley Happy mean= mean" means?

thank you.

Super Contributor
Posts: 1,636

Re: How to do the format Time value

You are welcome!

"output out="  creates a dataset," (drop=_Smiley Happy" 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=_Smiley Happy*/ mean=aaa /*mean*/;

run;

proc print data=new_dataset;run;

                       Obs    _TYPE_    _FREQ_      aaa

                          1          0              4           0:43

Contributor
Posts: 64

Re: How to do the format Time value

Thank you again, Have a great weekend!

Ask a Question
Discussion stats
  • 7 replies
  • 178 views
  • 9 likes
  • 3 in conversation