<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: OPEN Function with (keep= specifying absent variables is logging messages twice in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835410#M330283</link>
    <description>&lt;P&gt;How about to suppress these ERROR ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dkricond=nowarn dkrocond=nowarn ;
data _null_;
  dsid = open ('SASHELP.CLASS(keep=ANAME)');
  msg = sysmsg();
  put msg '(msg)';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Sep 2022 11:41:39 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-09-27T11:41:39Z</dc:date>
    <item>
      <title>OPEN Function with (keep= specifying absent variables is logging messages twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835257#M330224</link>
      <description>&lt;P&gt;Consider this step that keeps one unknown variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  dsid = open ('SASHELP.CLASS(keep=ANAME)');
  msg = sysmsg();
  put msg '(msg)';
run;&lt;BR /&gt;----- LOG -----&lt;BR /&gt;ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced. (msg)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SYSMSG() function retrieves the final message that would have been logged by the function.&lt;/P&gt;
&lt;P&gt;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().&amp;nbsp; Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  dsid = open ('SASHELP.CLASS(keep=ANAME SCHOOL)');
  msg = sysmsg();
  put msg '(msg)';
run;&lt;BR /&gt;----- LOG -----&lt;BR /&gt;ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;ERROR: The variable SCHOOL in the DROP, KEEP, or RENAME list has never been referenced. (msg)&lt;/PRE&gt;
&lt;P&gt;It gets worse as the number of unknown variables increases, because all the not-last error messages get logged twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  dsid = open ('SASHELP.CLASS(keep=&lt;STRONG&gt;ANAME&lt;/STRONG&gt; &lt;STRONG&gt;SCHOOL&lt;/STRONG&gt; NAME &lt;STRONG&gt;AHEIGHT&lt;/STRONG&gt; &lt;STRONG&gt;DISTRICT&lt;/STRONG&gt;)');
  msg = sysmsg();
  put msg '(msg)';
run;&lt;BR /&gt;----- LOG -----&lt;BR /&gt;ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;ERROR: The variable SCHOOL in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;ERROR: The variable AHEIGHT in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;ERROR: The variable ANAME in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;ERROR: The variable SCHOOL in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;ERROR: The variable AHEIGHT in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;ERROR: The variable DISTRICT in the DROP, KEEP, or RENAME list has never been referenced. (msg)&lt;/PRE&gt;
&lt;P&gt;Does anyone have any ideas on why this double logging occurs and how it might be reduced to single logging ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 19:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835257#M330224</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2022-09-26T19:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN Function with (keep= specifying absent variables is logging messages twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835263#M330227</link>
      <description>&lt;P&gt;One might ask why you are worried about a double error log in the first place.&lt;/P&gt;
&lt;P&gt;If you are relying on the LOG to tell you that variables aren't there perhaps you could consult with the Dictionary.columns (or sashelp.vcolumn) for the names you are using to verify that they are in the data set before attempting to open the set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run this code:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  dsid = open ('SASHELP.CLASS(keep=ANAME SCHOOL)');
  put "before msg";
  msg = sysmsg();
  put msg '(msg)';
run;&lt;/PRE&gt;
&lt;P&gt;You will see that the first too lines of errors in the log occur before the SYSMSG function executes. So one suspects the KEEP= errors are getting passed to the log. Then you get a (partial) duplicate from your SYSMSG/PUT combination.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 19:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835263#M330227</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-26T19:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN Function with (keep= specifying absent variables is logging messages twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835316#M330234</link>
      <description>&lt;P&gt;Hmm, in 9.4M7 I get two errors just from trying to keep one non-existant variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    data _null_;
2      dsid = open ('SASHELP.CLASS(keep=ANAME)');
3    run;

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.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;That's 9.4M7 on windows.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 20:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835316#M330234</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-09-26T20:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN Function with (keep= specifying absent variables is logging messages twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835390#M330278</link>
      <description>&lt;P&gt;If using below code the compiler reports the error once.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  stop;
  set SASHELP.CLASS(keep=ANAME SCHOOL NAME AHEIGHT DISTRICT);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So guess the open function then makes the compiler repeat the error message.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Feels like something you would need to contact SAS TS.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 08:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835390#M330278</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-09-27T08:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN Function with (keep= specifying absent variables is logging messages twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835397#M330279</link>
      <description>Hi Quentin:&lt;BR /&gt;&lt;BR /&gt;Pretty interesting how the logging changed between M6 and M7.&lt;BR /&gt;Hope it is not an indicator of a whack-a-mole situation.&lt;BR /&gt;&lt;BR /&gt;Richard</description>
      <pubDate>Tue, 27 Sep 2022 09:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835397#M330279</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2022-09-27T09:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN Function with (keep= specifying absent variables is logging messages twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835410#M330283</link>
      <description>&lt;P&gt;How about to suppress these ERROR ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dkricond=nowarn dkrocond=nowarn ;
data _null_;
  dsid = open ('SASHELP.CLASS(keep=ANAME)');
  msg = sysmsg();
  put msg '(msg)';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 11:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OPEN-Function-with-keep-specifying-absent-variables-is-logging/m-p/835410#M330283</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-27T11:41:39Z</dc:date>
    </item>
  </channel>
</rss>

