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
;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.