Error handling 我可以将关于未初始化变量的注释升级为错误吗

Error handling 我可以将关于未初始化变量的注释升级为错误吗,error-handling,sas,warnings,Error Handling,Sas,Warnings,当SAS遇到未初始化的变量时,它将向日志输出一条注释,如下所示: NOTE: Variable not_in_data is uninitialized. 是否可以让SAS将该消息作为警告或错误输出?是(在9.4或更高版本中): 选项varinitchk=错误 默认值为note,其他可能的值为nonote和warning 还有一个未记录的特性可以将某些注释更改为错误。您可以使用选项dsoptions=note2err设置该选项;或者将/note2err添加到数据语句中。我在SAS-L上找到了此

当SAS遇到未初始化的变量时,它将向日志输出一条注释,如下所示:

NOTE: Variable not_in_data is uninitialized.
是否可以让SAS将该消息作为警告或错误输出?

是(在9.4或更高版本中):

选项varinitchk=错误

默认值为
note
,其他可能的值为
nonote
warning

还有一个未记录的特性可以将某些注释更改为错误。您可以使用
选项dsoptions=note2err
设置该选项;或者将
/note2err
添加到数据语句中。我在SAS-L上找到了此选项更改为错误的注释列表:

19   Variable %*v is uninitialized.
97   Missing values were generated as a result of
98   Division by zero detected at %2q.
99   Mathematical operations could not be performed
108  Invalid numeric data, '%*s' , at %2q.
109  Invalid character data, %f , at %2q.
110  Invalid %sargument to function %b at %2q.
139  Argument to function %*s is not a known variable name:  %*v.
140  Argument to function %*s is not a valid variable name:  %*s.
205  Invalid argument(s) to the exponential operator "**" at %2q.
208  Invalid numeric data, %*s='%*s' , at %2q.
209  Invalid character data, %*s=%f , at %2q.
223  A number has become too large at %2q. %w%*s
224  A number has become too large during the compilation phase.
225  Division by zero detected during the compilation phase.
242  Invalid argument(s) to the exponential operator "**".
258  Invalid argument to function %*b at %2q.
259  Invalid first argument to function %*b at %2q.
260  Invalid second argument to function %*b at %2q.
261  Invalid third argument to function %*b at %2q.
262  Invalid fourth argument to function %*b at %2q.
267  Argument %d to function %*b at %2q is invalid.
356  The SUBSTR pseudo-variable function does not allow character
424  Character values have been converted to numeric
425  Numeric values have been converted to character
429  A number has become too large during the compilation phase,
430  Division by zero detected during the compilation phase,
484  Format %*b was not found or could not be loaded.
485  Informat %*b was not found or could not be loaded.

这太棒了。。。遗憾的是,他们没有扩展到其他方面,比如自动类型转换。实际上有一个未记录的功能,可以将某些注释更改为错误。您可以使用
option dsoptions=note2err或通过向特定数据步骤添加
/note2err
。这适用于未初始化的变量和隐式类型转换。我不知道它还可以转换哪些注释。dsoptions上的+1=note2err。它使许多坏音符变成了错误。希望有一天他们能将它记录下来,使之成为官方文件。@Dwal这太棒了。多年来我一直在寻找类似的东西。我认为你应该在你的回答中提到这一点,使之更加突出。在我看来,这些注释中的大多数实际上是错误的。太多人巧合地编程()不幸的是SAS似乎支持它。。。这类似于为什么在VBA中使用OPTION EXPLICIT将潜在问题提升为错误是一种良好的编程实践。请参见此处的讨论: