BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

In my data the following values present for a time variable.

 

When I used put function to convert to character, I am getting different values eventhough the time values are same. Any suggestions. Please help. Thanks

 

 code; Time1=put(time,time8.);

 

 

Data

 

ID           Time(numeric)

1            00:00:00

1            00:00:00

 

output getting;

ID             Time                        time1

1            00:00:00                    0:00:00

1            00:00:00                    24:00:00

 

3 REPLIES 3
Reeza
Super User

Are there no other components to the date, such as a decimal or a day value?

 

Most likely this is a numerical precision issue. If you round it to the nearest integer and format it should work as expected.

 

Try

 

time_char = put(round(time, 1), time8.);

FYI - I could not replicate your issue. 

Kurt_Bremser
Super User

And once you've verified that you have a "numerical precision artifact" in your time value, just use the round() function to get rid of it.

timeval = round(timeval,.000001);

will remove a small fractional error while preserving time down to microseconds.

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!

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
  • 3 replies
  • 641 views
  • 3 likes
  • 3 in conversation