BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8


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;

1 ACCEPTED SOLUTION

Accepted Solutions
Vince28_Statcan
Quartz | Level 8

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;

View solution in original post

1 REPLY 1
Vince28_Statcan
Quartz | Level 8

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 1983 views
  • 0 likes
  • 2 in conversation