1

SAS 可以存储和使用包含小于 1/10 秒的分数的日期时间吗?

例如:

data _null_;
input @1 from_dt:datetime22.;
put from_dt= ;
cards;      
24Sep2009:11:21:19.856
;
run;
4

3 回答 3

2

您的示例代码在打印输出上四舍五入。在 put 语句上添加格式(例如 best32.)表明存在更好的精度......

data _null_; 
input @1 from_dt:datetime22.; 
put from_dt= best32.; 
cards;
24Sep2009:11:21:19.856 
; 
run; 

from_dt=1569410479.856
于 2009-09-24T23:11:42.033 回答
2

日期时间变量是一个数值变量,就像任何其他数值变量一样。我们只是将其值理解为自 01jan1960T00:00:00 以来的秒数。希望这可以帮助。

data _null_;

  /* for date time, 1 means 1 sec since midnight jan 1st 1960 */
  dt = 1;
  put dt :datetime.;

  /* you can show the hundredth of second using datetime format */
  dt = 0.01;
  put dt :datetime19.2;

  /* but it is just a double type number. you can do
     what you want with the variable as with any other numeric
     variables */
  dt = 0.01;
  put "It was " dt :wordf15. "second after midnight.";
run;
/* on log
01JAN60:00:00:01
01JAN60:00:00:00.01
it was zero and 01/100 second after midnight.
*/
于 2009-09-25T16:19:02.933 回答
1

正如 Rog 指出的那样,您可以以超过 0.1 秒的精度读取和存储日期时间。

只需使用 datetime22.3 或类似的格式和信息,而不是 datetime22。

于 2009-09-25T10:40:51.727 回答