Hi everyone, I have challenge formating time.
I'm trying to create time format from time().
For example, I want it in 5:25(I don't want pm or am attached to time). What I'm getting is either 5:25pm and 17:25.
data _null_;
call symputx('time', put(time, tod5.));
run;
%put &=time;
I have tried using time5. timeampm. as well.
None is working.
What can I do please?
Roll your own picture format with '%0I:%0M' (%I displays hour in 12-hour format).
Since you seem to be putting the value into a macro variable just add more logic.
Either after you have converted the time into a string.
1 data _null_;
2 time='17:25't ;
3 call symputx('time', substr(put(time, timeampm.),1,5));
4 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
5 %put &=time;
TIME=5:25
6
Or before
7 data _null_;
8 time='17:25't ;
9 call symputx('time', put(mod(time,'12:00:00't), time5.));
10 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
11 %put &=time;
TIME=5:25
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.