SAS 信息日期时间毫秒

发布于 2024-08-05 21:34:14 字数 179 浏览 6 评论 0原文

SAS 能否存储和使用包含小于 1/10 秒的小数部分的日期时间?

例如:

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

Can SAS store and use datetimes that contain fractions of less than 1/10th of a second?

eg:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

晚雾 2024-08-12 21:34:14

日期时间变量是一个数值变量,就像任何其他数值变量一样。我们只是将其值理解为自 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.
*/

A datetime variable is a numeric variable just like any other numeric variables. We just understand its value as the seconds since 01jan1960T00:00:00. Hope this helps.

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.
*/
花期渐远 2024-08-12 21:34:14

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

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

from_dt=1569410479.856

Your sample code is rounding on the printed output. Adding a format (eg best32.) on the put statement shows that there is better precision being held...

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

from_dt=1569410479.856
笙痞 2024-08-12 21:34:14

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

只需使用 datetime22.3 或类似的格式和信息来代替 datetime22。

As Rog pointed out, you can read in and store datetimes with more precision than .1 sec.

Just use the datetime22.3 or a similar format and informat instead of datetime22.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文