Consider this step that keeps one unknown variable
data _null_;
dsid = open ('SASHELP.CLASS(keep=ANAME)');
msg = sysmsg();
put msg '(msg)';
run; ----- LOG ----- ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced. (msg)
The SYSMSG() function retrieves the final message that would have been logged by the function.
If there are two unknown variables in the keep= there is some log messiness because the first error message (also the 'not last' error messages) is logged by SAS and repeated, and the last message is not logged and can be retrieved with SYSMSG(). Example:
data _null_;
dsid = open ('SASHELP.CLASS(keep=ANAME SCHOOL)');
msg = sysmsg();
put msg '(msg)';
run; ----- LOG ----- ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable SCHOOL in the DROP, KEEP, or RENAME list has never been referenced. (msg)
It gets worse as the number of unknown variables increases, because all the not-last error messages get logged twice.
data _null_;
dsid = open ('SASHELP.CLASS(keep=ANAME SCHOOL NAME AHEIGHT DISTRICT)');
msg = sysmsg();
put msg '(msg)';
run; ----- LOG ----- ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable SCHOOL in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable AHEIGHT in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable SCHOOL in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable AHEIGHT in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable DISTRICT in the DROP, KEEP, or RENAME list has never been referenced. (msg)
Does anyone have any ideas on why this double logging occurs and how it might be reduced to single logging ?
... View more