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

Read in CSV format file with time information, with format TIME20.3. 

The time column has millisecond, like 9:15:30:050 (050 is the millisecond).

 

Here are hour/minute/second functions to use. Any function to fetch the millisecond information ?!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Try MOD() function:

millisecond=mod( time ,1);

View solution in original post

5 REPLIES 5
hellohere
Pyrite | Level 9
second() can do that, actually.
Ksharp
Super User
Try MOD() function:

millisecond=mod( time ,1);
Kurt_Bremser
Super User

Does your time string actually look like this:

9:15:30:050

The default TIME informat cannot read this, because of the semicolon between the seconds and the fractional part.

So I ask: is this a typo, or do we need to take care of this non-standard time format?

hellohere
Pyrite | Level 9
Yeah, you guys are right. it is . not :
Sajid01
Meteorite | Level 14

Hello @hellohere 

The time values should have a decimal point and not semicolon before milliSeconds.
With that the following code will work

data test;
informat tm time20.3;
format tm time20.3;
input tm;
time_milliS=mod(tm,1);
datalines;
9:15:30.050
;;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 769 views
  • 1 like
  • 4 in conversation