如何在SAS日志中删除警告消息
当我将记录插入表
“警告:字符表达式将被截断为字符列inputjob时,
我如何停止将此消息写入SAS日志,因此我的作业返回代码时, 下面的警告消息将写入SAS日志中。将是0而不是4
%MACRO INSDRY(inpdsn);
data _NULL_;
set DB2TS;
length jobname $8 jobid $8;
tiotptr = peek(peek(540)+12);
jobname = peekc(tiotptr,8);
jscbptr = peek(peek(540)+180);
ssibptr = peek(jscbptr+316);
jobid = peekc(ssibptr+15,5);
inputjob = jobname || ' ' || "JOB" || jobid;
call symputx('inputjob',inputjob);
run;
proc sql;
insert into table
(filename, inputjob)
values
(%sysfunc(quote(&inpdsn)),%sysfunc(quote(&inputjob)));
quit;
%MEND;
do i=1 to f_count;
set ftp_dir_list point=i nobs=f_count;
if prxmatch(iPat_RE, trim(dir_file)) > 0 then do;
iFTP_DSN = dir_file;
CALL EXECUTE (cats('%INSDRY(',trim(iFTP_DSN),');'));
incount+1;
found+1;
end;
end;
获取列的警告消息,该列input_job定义为17位数字,我得到的值也是17位数字。
删除宏时,我不会收到此警告。
Below warning message is being written into the SAS LOG when I Insert a Record into a table
"WARNING: Character expression will be truncated when assigned to character column inputjob"
How can I stop writing this message into the SAS lOG, So my job return code will be 0 instead of 4
%MACRO INSDRY(inpdsn);
data _NULL_;
set DB2TS;
length jobname $8 jobid $8;
tiotptr = peek(peek(540)+12);
jobname = peekc(tiotptr,8);
jscbptr = peek(peek(540)+180);
ssibptr = peek(jscbptr+316);
jobid = peekc(ssibptr+15,5);
inputjob = jobname || ' ' || "JOB" || jobid;
call symputx('inputjob',inputjob);
run;
proc sql;
insert into table
(filename, inputjob)
values
(%sysfunc(quote(&inpdsn)),%sysfunc(quote(&inputjob)));
quit;
%MEND;
do i=1 to f_count;
set ftp_dir_list point=i nobs=f_count;
if prxmatch(iPat_RE, trim(dir_file)) > 0 then do;
iFTP_DSN = dir_file;
CALL EXECUTE (cats('%INSDRY(',trim(iFTP_DSN),');'));
incount+1;
found+1;
end;
end;
Getting the warning message for the column input_job which is defined as 17 digits, value i get is also 17 digits.
I am not getting this warning when I remove the macro.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我看不到任何数据步骤。我看到了一个宏定义(这应该是代码中的第一件事,因为它只是一个定义,而不是实际执行)。
如果要通过呼叫execute()调用宏观,请确保至少包围%nrstr()宏函数的%insdry,以防止SAS在呼叫执行语句执行时执行宏。这只会将宏生成的SAS语句推到数据步骤结束后要执行的堆栈上。相反,您希望将宏调用本身添加到堆栈中,以便在数据步骤结束后将执行。
如果宏引用的宏变量通过宏生成的SAS代码更改其值的宏变量,则尤其如此。在您的情况下,调用Symputx()语句。因此,当宏尝试使用宏变量生成代码时,尚未设置其值,因为设置其值的语句仍在等待运行。
因此程序流应该是这样的:
I don't see any DATA step. I see a macro definition (which should be the first thing in the code since it is just a definition, not actually an execution).
If you are calling a macro via CALL EXECUTE() make sure to surround at least the %INSDRY with %NRSTR() macro function to prevent SAS from executing the macro when the CALL EXECUTE statement executes. That will just push the SAS statements the macro generates onto a stack to be executed after the data step ends. Instead you want the macro call itself to be added to the stack so that it will execute after the data step ends.
This is especially true if the macro references macro variables whose values are changed by the SAS code that the macro generates. In your case the CALL SYMPUTX() statement. So when the macro is trying generate the code using the macro variable its value is not yet set because the statements that will set its value are still waiting to run.
So the program flow should be something like this:
Jobname
和JobID
均为$ 8,因此,串联分配语句将隐式创建变量
inputjob
长度$ 20
。从串联中删除
“ job”
,您将以$ 17
为单位。很多时候,最好在步骤开始时代码<代码>长度 attrib 语句,以确保您明确定义PDV中的变量。
JobName
andJobId
are both $8, so the concatenation assignment statementwill implicitly create variable
inputjob
of length$20
.Remove
"JOB"
from the concatenation and you will be at$17
.Many times it is best to code a
length
orattrib
statement at the start of the step to ensure you explicitly define variables in the PDV.