Hi all,
this is probably an easy one but today my brain is not working.
I have the numeric variable time with e.g. the values 12, 15, 18, ... . Those values should be converted to a SAS time format representing the clock time e.g. 12:00, 15:00, 18:00.
Could you help me to figure out the code?
Thanks a lot
Mealie
get those brains on, I hope there is an on/off switch....
Time and dates are numerics they are nice presented by SAS formats. The only thing I could make up is you are having some number that is in hours.
60 minutes in an hour with 60 seconds and you get the time in seconds. That is the SAS standard of time measurement.
get those brains on, I hope there is an on/off switch....
Time and dates are numerics they are nice presented by SAS formats. The only thing I could make up is you are having some number that is in hours.
60 minutes in an hour with 60 seconds and you get the time in seconds. That is the SAS standard of time measurement.
Thank you, this works 🙂
DATA new;
Set old;
time_new= time_old * 3600;
FORMAT time_new hhmm.;
Run;
Hi,
your_new_time_variable=hms(your_number_variable,0,0);
The SAS function HMS looks like what you need. The 3 arguments are hour, minute, and second. Just use 0 for minute and second. You may need to format the resulting number in your favorite time format.
data _null_;
ref = hms(13, 0, 0);
put ref /
ref time.;
run;
data have;
input t;
time=t*3600;
format time time5.;
datalines;
12
14
15
;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.