turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- TIMEPART

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-09-2013 11:30 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to robertrao

10-09-2013 11:45 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to robertrao

10-09-2013 11:45 AM

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;