BookmarkSubscribeRSS Feed
JJP1
Pyrite | Level 9

Hi
Iam having date valus as "25JAN2019:13:30:59.590000" in one of the SAS dataset.
and iam using timepart(25JAN2019:13:30:59.590000) function and format and informat as tim8.
Iam getting below time value
13:31:38
Iam unable to understand why 59 is getting changed to 38 please.please help how it reallly works

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Please post your entire code. This works fine

 

data _null_;
    dt="25JAN2019:13:30:59.590000"dt;
    t=timepart(dt);
    put dt= // t= time8.;
run;
JJP1
Pyrite | Level 9

Hi @PeterClemmensen ,

the function is used in SAS DI in table loader transformation with timepart() and informat and format as "TIME8.".

so i just wanted to know how timepart(25JAN2019:13:30:59.590000) is giving result as below for fomar and informat time8.is this correct please.iam trying to under stand how 13:31:38 is getting created from above date

 

13:31:38 

Tom
Super User Tom
Super User

The TIMEPART() function is NOT the issue.

Look for the answer somewhere else.

Are you sure about the original value.

How did you convert that string into a datetime value.

Did you perhaps store it into a SAS variable that used less than the full 8 bytes to store the value?  That can cause some loss of precision on numbers.  The number of seconds that are stored for that datetime value is:  1,864,042,259.590000

 

ballardw
Super User

@JJP1 wrote:

Hi
Iam having date valus as "25JAN2019:13:30:59.590000" in one of the SAS dataset.
and iam using timepart(25JAN2019:13:30:59.590000) function and format and informat as tim8.
Iam getting below time value
13:31:38
Iam unable to understand why 59 is getting changed to 38 please.please help how it reallly works


I would expect to see a 13:31:00 if some rounding went on but strongly suspect some other manipulation to get 38 seconds.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 4 replies
  • 1257 views
  • 0 likes
  • 4 in conversation