date - 无法在宏中执行 Sas INTCK
问题描述
我正在运行以下宏:
%macro diff(yymm);
%let date1=%sysfunc(inputn(strip(putn(&yymm.,yymmn6.))||'01',yymmdd10.));
%let date2=%sysfunc(inputn(strip(putn(201811,yymmn6.))||'01',yymmdd10.));
%let j=%sysfunc(intck(month,&date1.,&date2.));
%put &date1. &date2. &j.;
%mend;
%diff(201807);
%diff(201808);
基本上是为了找出从 18 年 11 月到我作为参数传递给这个宏的任何日期的月份差异。我不确定我哪里出错了,但我收到以下错误:
Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set
to a missing value.
有人可以在这里帮助我吗?
解决方案
YYMMN6。informat 不会被识别strip(
为有效的日期值。如果不将每个函数包装在宏函数中,就不能在宏代码中调用函数%sysfunc()
,它们看起来就像宏处理器的字母。
这是你想要做的吗?
%macro diff(yymm);
%put &yymm 201811 %sysfunc(intck(month,%sysfunc(inputn(&yymm, yymmn6.)),'01NOV2018'd));
%mend;
结果:
1104 %diff(201807);
201807 201811 4
1105 %diff(201808);
201808 201811 3
推荐阅读
- javascript - jQuery插件在鼠标悬停时关闭下拉菜单
- angular - 在提供者 Angular 5 中注入服务?
- html - Why is there a white space between my button and its border?
- amazon-web-services - Nomad UI 显示更少的客户端/服务器节点
- jquery - Ajax 加载更多内容
- python - 如何在 Python 中为 Postgres 自动生成 UUID?
- javascript - Javascript 使用基于 DD/MM/YYYY 的正则表达式将文本从文件拆分为数组
- python - 基于值维度的列表迭代字典理解
- jsonpath - AWS Glue 自定义分类器 Json 路径
- java - 从多对多关系的两个表中获取记录