将时间戳转换为SAS中的数字值

发布于 2025-01-24 17:52:35 字数 248 浏览 0 评论 0原文

如何将默认时间戳“ 0001-01-01-00.00.00.000000”转换为SAS,我尝试了以下代码,但已返回null值。有人可以帮忙吗

data _NULL_;

x = "0001-01-01-00.00.00.000000";

rlstime = input(x,anydtdtm26.);

call symput('rlstime',rlstime);

run;

%put rlst: &rlstime;

How to convert the default timestamp "0001-01-01-00.00.00.000000" in SAS, i have tried below code but it has returned null value. Can someone help on this please

data _NULL_;

x = "0001-01-01-00.00.00.000000";

rlstime = input(x,anydtdtm26.);

call symput('rlstime',rlstime);

run;

%put rlst: &rlstime;

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

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

发布评论

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

评论(2

绳情 2025-01-31 17:52:36

SAS处理的最早日期是1582年1月1日。此外,应使用结肠字符来界定日期以及小时,分钟和秒的时间。因此,您的代码可以调整为以下内容:

data _NULL_;
  x = "1582-01-01:00:00:00.000000";
  rlstime = input(x,anydtdtm26.);
  call symput('rlstime',rlstime);
run;
%put rlst: &rlstime;

The earliest date that SAS will handle is 1st January, 1582. Additionally, a colon character should be used to delimit the time from the date, as well as the hours, minutes and seconds. Therefore, your code may be adjusted to the following:

data _NULL_;
  x = "1582-01-01:00:00:00.000000";
  rlstime = input(x,anydtdtm26.);
  call symput('rlstime',rlstime);
run;
%put rlst: &rlstime;
舟遥客 2025-01-31 17:52:35

据我记得,SAS无法做到这一点。 SAS不存在1.1.1600之前的任何日期/时间戳。您需要它还是可以用无效的值替换它?如果您真的需要它,则可以将其转换为另一个有效的时间戳,将其分为不同的列(年,月份等),或将其用作字符串。在您的示例中,您只需将时间戳写入日志中,这意味着不需要对其进行转换。

As far as I remember, SAS cannot do that. Any date/timestamp before 1.1.1600 doesn't exist for SAS. Do you need it or can you just replace it with a null value? If you really need it you could transform it into another valid timestamp, split it into different columns (year, month, etc.) or just use it as a string. In your example you just write the timestamp into the log, meaning it's not necessary to transform it.

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