在SAS中使用INTNX时“无效的第二个参数”(“Invalid 2nd argument” when using INTNX in SAS)

编程入门 行业动态 更新时间:2024-10-20 05:47:40
在SAS中使用INTNX时“无效的第二个参数”(“Invalid 2nd argument” when using INTNX in SAS)

我有一个数据集,有一个名为date的变量。 它看起来像“31MAY13:00:00:00”,其数据类型是日期。 现在我想创建一个新变量,使其成为相应月份的第一天。 所以对于“31MAY13:00:00:00”,它会给我“01MAY13:00:00:00”。 这是我的代码:

DATA newdata; SET olddata; newvariable = INTNX('month',olddate,0,"B"); RUN;

日志说:函数INTNX的参数2无效。 我和SAS合作已经有一段时间了。 任何想法? 非常感谢!

I have a dataset and there is a variable called date. It looks like "31MAY13:00:00:00" and its datatype is date. Now I want to create a new variable such that it is the first day of the corresponding month. So for "31MAY13:00:00:00", it will give me "01MAY13:00:00:00". Here's my code:

DATA newdata; SET olddata; newvariable = INTNX('month',olddate,0,"B"); RUN;

The log says: Argument 2 to function INTNX is invalid. It's been a while working with SAS for me. Any idea? Thank you so much!

最满意答案

您的值是日期时间,而不是日期。 您需要将dt添加到区间的前面,以增加日期时间值:

DATA newdata; SET olddata; newvariable = INTNX('dtmonth',olddate,0,"B"); RUN;

Your value is a datetime, not a date. You need to add dt to the front of the interval like this to increment a datetime value:

DATA newdata; SET olddata; newvariable = INTNX('dtmonth',olddate,0,"B"); RUN;

更多推荐

本文发布于:2023-08-01 14:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第二个   参数   INTNX   SAS   Invalid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!