BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KubiK888
Calcite | Level 5

I have a column with HH:MM in a string format, I would like it to be converted into HHMw.d time format.

 

In EG, I go to Query Builder and advanced expression with "INPUT(t1.time_v2, HHMMw.)", it created a new variable but they are all missing (.).

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@KubiK888 wrote:
Thanks, but it turns it into 5-digit number. For example "7:57" into 28620.

That's likely correct. Now you need to apply a format to it as well, TIME. 

 

SAS stores times as the number of seconds and dates as the number of days. 

View solution in original post

6 REPLIES 6
collinelliot
Barite | Level 11

Are you actually putting "w" as the length? That should actually be a number or potentially nothing. You're not getting any kind of note or error?

KubiK888
Calcite | Level 5

I am not getting any error. But there is note: Invalid string for 

 

234 t1.time_v2,
235 /* time_v3 */
236 (INPUT(t1.time_v2, HHMM.)) AS time_v3
237 FROM WORK.QUERY_FOR_UNDERSTANDI_0003 t1;

 

And with and without "w" doesn't make a difference, just create a new column with all empty value.

Reeza
Super User

Are you sure it's a string format? Can you show a proc contents and a few values?

ballardw
Super User

Try TIME5. instead of HHMMw. if you only have hour and minutes.

HHMMw. is a display format, not an informat.

 

I would expect an error similar to this:

355  data junk;
356     time_v2 = "12:34";
357     tt =INPUT(time_v2, HHMM.);
                           -----
                           485
NOTE 485-185: Informat HHMM was not found or could not be loaded.

358  run;
KubiK888
Calcite | Level 5
Thanks, but it turns it into 5-digit number. For example "7:57" into 28620.
Reeza
Super User

@KubiK888 wrote:
Thanks, but it turns it into 5-digit number. For example "7:57" into 28620.

That's likely correct. Now you need to apply a format to it as well, TIME. 

 

SAS stores times as the number of seconds and dates as the number of days. 

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 7207 views
  • 0 likes
  • 4 in conversation