Thursday, June 23, 2016

SAS: Negative times

If a time value is negative, it could lose the sign depending on the format you choose... Format timew. assumes time, whereas todw. assumes datetime.




data _null_ ;
   format __TIME TIME10. ;
   minutes = -23;
   __TIME = minutes * 60;
   format __TOD10 TOD10. ;
   __TOD10 = minutes * 60;
   __IN_MINUTES = intck( "MINUTES" , 0 , __TIME ) ;
   put _all_ ;
run;



Log

1    data _null_ ;
2       format __TIME TIME10. ;
3       minutes = -23;
4       __TIME = minutes * 60;
5       format __TOD10 TOD10. ;
6       __TOD10 = minutes * 60;
7       __IN_MINUTES = intck( "MINUTES" , 0 , __TIME ) ;
8       put _all_ ;
9    run;

__TIME=-0:23:00 minutes=-23 __TOD10=23:37:00 __IN_MINUTES=-23 _ERROR_=0 _N_=1
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds


No comments:

Post a Comment