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!
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.