Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dynamic 使用带有月份+;年份(mmyy)SAS EG_Dynamic_Tablename - Fatal编程技术网

Dynamic 使用带有月份+;年份(mmyy)SAS EG

Dynamic 使用带有月份+;年份(mmyy)SAS EG,dynamic,tablename,Dynamic,Tablename,需要帮忙吗? 当显示变量vMonth时,它正在工作,但当将其与库名称连接时,会出现以下问题 节目: %LET lastdaypreviousmonth = put(intnx('month', today(), -1, 'E'),mmyyn4.); %LET vMonth = cats('RM',&lastdaypreviousmonth); PROC SQL; SELECT &vMonth,* FROM MASU.&vMonth WHERE nsgr = '040';

需要帮忙吗? 当显示变量vMonth时,它正在工作,但当将其与库名称连接时,会出现以下问题

节目:

%LET lastdaypreviousmonth = put(intnx('month', today(), -1, 'E'),mmyyn4.);
%LET vMonth = cats('RM',&lastdaypreviousmonth); 
PROC SQL;
SELECT &vMonth,*
FROM MASU.&vMonth
WHERE nsgr = '040';
QUIT;
27         %LET lastdaypreviousmonth = put(intnx('month', today(), -1, 'E'),mmyyn4.);
28         %LET vMonth = cats('RM',&lastdaypreviousmonth);
29        
30         PROC SQL;
31        
32         SELECT &vMonth,*
33         FROM MASU.&vMonth
34         WHERE nsgr = '040';

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.

NOTE: Line generated by the macro variable "VMONTH".

34          MASU.cats('RM',put(intnx('month', today(), -1, 'E'),mmyyn4.))

                          _                                    _

                          79                                   79

                                                               200

ERROR 79-322: Expecting a ).

 

ERROR 200-322: The symbol is not recognized and will be ignored.
日志文件:

%LET lastdaypreviousmonth = put(intnx('month', today(), -1, 'E'),mmyyn4.);
%LET vMonth = cats('RM',&lastdaypreviousmonth); 
PROC SQL;
SELECT &vMonth,*
FROM MASU.&vMonth
WHERE nsgr = '040';
QUIT;
27         %LET lastdaypreviousmonth = put(intnx('month', today(), -1, 'E'),mmyyn4.);
28         %LET vMonth = cats('RM',&lastdaypreviousmonth);
29        
30         PROC SQL;
31        
32         SELECT &vMonth,*
33         FROM MASU.&vMonth
34         WHERE nsgr = '040';

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.

NOTE: Line generated by the macro variable "VMONTH".

34          MASU.cats('RM',put(intnx('month', today(), -1, 'E'),mmyyn4.))

                          _                                    _

                          79                                   79

                                                               200

ERROR 79-322: Expecting a ).

 

ERROR 200-322: The symbol is not recognized and will be ignored.

宏代码只是执行您让它执行的操作。添加一些%PUT语句,查看您在宏变量中输入了哪些值。宏处理器处理字符串的方式与处理字符串的方式没有任何区别,例如
put
cats

如果要在宏代码中调用SAS函数,则需要使用
%sysfunc()
宏函数包装每次调用。并非所有函数都可以这样调用。特别是,flexible PUT()和INPUT()函数不是使用类型特定的版本,而是使用类型特定的版本。但是在这种情况下,您可以只使用%SYSFUNC()调用的format参数,而不是函数调用。不要在字符串文本中包含引号,对于宏处理器来说,所有内容都是字符串文本

使用以下命令:

%LET lastdaypreviousmonth=%sysfunc(intnx(month,%sysfunc(today()),-1, E),mmyyn4.);
没有必要在宏代码中使用CAT…()函数。若要连接宏变量值,只需在希望它们出现的位置展开它们

%LET vMonth = RM&lastdaypreviousmonth.;

非常感谢汤姆!没有遇到错误,但是数据集返回与原始表不匹配。返回的列数减少了,有什么想法吗?