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!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.