Hi there
I am trying to convert this text so I can use the time element in SAS.?
12:30PM:Tuesday:Weekday
7:30AM:Tuesday:Weekday
6:60AM:Saturday:Weekend
currently stored as CHAR $25
I have managed to extract the time by doing the following but it is still text so cant use to sort by time
time= Substr(text_,1,index(text_,"M:"));
How can I then convert to a SAS format
thanks
Your data needs a day, month and a year.
The date sits in a separate text field
September 1, 2015
Hi yes and I have managed to get that but it is in a char format so when I sort by it, it's not sorting correctly... ie I need 7:30am before 12.30pm etc
not elegant but it works.
data one;
informat time $25. ;
input time ;
cards;
12:30PM:Tuesday:Weekday
7:30AM:Tuesday:Weekday
6:60AM:Saturday:Weekend
;
run;
data want;
set one;
time2=scan(time,1,'M')||'M';
run;
proc print;
run;
Excellent thanks this works great ![]()
In general, the idea is the same as your earlier date question. Use input() with appropriate informat.
Assuming you've isolated the time portiom correctly it will be something like:
Time_sas = input(time, time.);
Thanks @Reeza that works and allows me to sort but is there a way of showing it in a format that is easy to understand ie 10:00AM and not 36000
Apply a format.
format time_sas time8.;
Excellent thank you!
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 lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.