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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 5 replies
  • 364 views
  • 1 like
  • 4 in conversation