## TIMEPART

Solved
Super Contributor
Posts: 1,041

# TIMEPART

I have time like this:

TIME

23AUG2013:15:12:00.000

28AUG2013:19:22:00.000

If i want to remove the record where timpepart is zeros.....

data want;

set have;

where timepart(TIME) ne 0));   /*why just a single zero is enough*/

run;

why cant I do:

data want;

set have;

where timepart(TIME) ne 00:00:00.000));

run;

Accepted Solutions
Solution
‎10-09-2013 11:45 AM
Super Contributor
Posts: 339

## Re: TIMEPART

Posted in reply to robertrao

SAS stores dates, time and datetime values as numeric. It is merely a format that converts the value to something meaningful to the human.

A date, is the number of days since 01JAN1960

A time, is the number of seconds(floats for fractions of seconds) since 00:00:00.000

A datetime, is the number of seconds since 01JAN1960:00:00:00.000

data _null_;

date="01FEB2011"d;

put date=; /* shows the unformated value of date, that is the number of days between 01jan1960 and 01feb2011 */

time="00:10:05.03"t;

put time=; /* shows the unformated number of seconds since 00:00:00.000 after 10 minutes 5 seconds and .03 hundredth of seconds */

datetime="01FEB2011:00:10:05.03"dt;

put datetime=;

run;

So 00:00:00.000 is not an interpretable number by SAS. You could do where timepart(time) NE "00:00:00.000"t; but then that would simply be you asking SAS to convert "00:00:00.000" to its own representation of counting seconds. Since it is known/documented how it is counted, we know it's equal to 0 in its internal representation and thus simply write where timepart(time) NE 0;

All Replies
Solution
‎10-09-2013 11:45 AM
Super Contributor
Posts: 339

## Re: TIMEPART

Posted in reply to robertrao

SAS stores dates, time and datetime values as numeric. It is merely a format that converts the value to something meaningful to the human.

A date, is the number of days since 01JAN1960

A time, is the number of seconds(floats for fractions of seconds) since 00:00:00.000

A datetime, is the number of seconds since 01JAN1960:00:00:00.000

data _null_;

date="01FEB2011"d;

put date=; /* shows the unformated value of date, that is the number of days between 01jan1960 and 01feb2011 */

time="00:10:05.03"t;

put time=; /* shows the unformated number of seconds since 00:00:00.000 after 10 minutes 5 seconds and .03 hundredth of seconds */

datetime="01FEB2011:00:10:05.03"dt;

put datetime=;

run;

So 00:00:00.000 is not an interpretable number by SAS. You could do where timepart(time) NE "00:00:00.000"t; but then that would simply be you asking SAS to convert "00:00:00.000" to its own representation of counting seconds. Since it is known/documented how it is counted, we know it's equal to 0 in its internal representation and thus simply write where timepart(time) NE 0;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 1 reply
• 666 views
• 0 likes
• 2 in conversation