<?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: Issue with PROC COMPARE return code and VAR statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646974#M193581</link>
    <description>Hi Chris&lt;BR /&gt;&lt;BR /&gt;Thanks for response. I agree that the BASE table is the reference and I accept that this is how SAS constructs the list of variables when the VAR statement is specified. I suppose my question, probably unanswerable, is how does SAS construct the list of variables when the VAR statement is not specified and why does this differ when the abbreviated syntax is used?</description>
    <pubDate>Tue, 12 May 2020 06:26:25 GMT</pubDate>
    <dc:creator>RolandTower</dc:creator>
    <dc:date>2020-05-12T06:26:25Z</dc:date>
    <item>
      <title>Issue with PROC COMPARE return code and VAR statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646958#M193573</link>
      <description>&lt;P&gt;Hi everyone&lt;/P&gt;&lt;P&gt;I have the following code that creates two datasets - _TEST123 has 3 variables, and _TEST12 has 2 variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;A PROC COMPARE with _TEST123 as the BASE dataset and _TEST12 as the COMPARE dataset gives a return code of 1024, indicating that the "Base dataset has variable not in comparison".&amp;nbsp;&lt;/P&gt;&lt;P&gt;A PROC COMPARE with _TEST12 as the BASE dataset and _TEST123 as the COMPARE dataset gives a return code of 0, indicating no issues, even though the actual PROC COMPARE output indicates that the variable X3 is in the COMPARE dataset but not the BASE dataset.&amp;nbsp; &amp;nbsp;The return code of 0 is not the value that what I would expect.&lt;/P&gt;&lt;P&gt;I believe that the reason the return code is equal to 0 in the second compare is that I am using the VAR statement with X:, which gets SAS to create the list of variables from those present in both the BASE and COMPARE dataset or in the BASE dataset only (this comes from the VAR statement documentation).&amp;nbsp; This then means that X3 gets omitted by SAS from the VAR statement and hence the return code of 0 is obtained.&amp;nbsp; If you drop the VAR statement from the PROC COMPARE then you get the results I would expect, which is a return code of 2048 for the second compare.&lt;/P&gt;&lt;P&gt;So to my question:&amp;nbsp; Is it wrong to expect the second PROC COMPARE step below, with the VAR statement in place, to give a return code of 2048 (i.e. is the return code of 0 what I should expect)?&amp;nbsp; I am pretty sure I know why I get a result of 0, but I don't think that SAS should be giving me that result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;STRONG&gt;/* data creation&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;data _test123;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do subjid = 1 to 10;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1&amp;nbsp;&amp;nbsp; = 1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x2&amp;nbsp;&amp;nbsp; = 2 + subjid;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x3&amp;nbsp;&amp;nbsp; = 3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;data _test12;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do subjid = 1 to 10;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1&amp;nbsp;&amp;nbsp; = 1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x2&amp;nbsp;&amp;nbsp; = 2 + subjid;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;STRONG&gt;/* COMPARE #1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;proc compare base=_test123 compare=_test12 out=_outnoequal outnoequal method=absolute listall;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id subjid;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var x:;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;%put PROC COMPARE return code = &amp;amp;sysinfo;&amp;nbsp; /* returns the expected value of 1024 */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;STRONG&gt;/* COMPARE #2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;proc compare base=_test12 compare=_test123 out=_outnoequal outnoequal method=absolute listall;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id subjid;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var x:;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;%put PROC COMPARE return code = &amp;amp;sysinfo;&amp;nbsp; /* returns a value of 0 */&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 04:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646958#M193573</guid>
      <dc:creator>RolandTower</dc:creator>
      <dc:date>2020-05-12T04:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with PROC COMPARE return code and VAR statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646966#M193575</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;&amp;nbsp;Is it wrong to expect the second PROC COMPARE step below, with the VAR statement in place, to give a return code of 2048 (i.e. is the return code of 0 what I should expect)?&lt;/EM&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You specifically supply a list of variables. So SAS only compares these variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Since you let SAS build that list by using an abbreviated syntax it uses the BASE table for that purpose.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The same would happen if you used another abbreviated syntax, for example &lt;FONT face="courier new,courier"&gt;_numeric_&lt;/FONT&gt; .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now the question is: Should SAS use both tables to build that list?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I didn't find any documentation&amp;nbsp;about this, but the&amp;nbsp;&lt;/SPAN&gt;observed&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;behaviour makes sense to me.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The base table is the reference. The other table is compared to that reference.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Building the list from that reference rather than any other source seems perfectly coherent.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 05:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646966#M193575</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-12T05:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with PROC COMPARE return code and VAR statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646974#M193581</link>
      <description>Hi Chris&lt;BR /&gt;&lt;BR /&gt;Thanks for response. I agree that the BASE table is the reference and I accept that this is how SAS constructs the list of variables when the VAR statement is specified. I suppose my question, probably unanswerable, is how does SAS construct the list of variables when the VAR statement is not specified and why does this differ when the abbreviated syntax is used?</description>
      <pubDate>Tue, 12 May 2020 06:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646974#M193581</guid>
      <dc:creator>RolandTower</dc:creator>
      <dc:date>2020-05-12T06:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with PROC COMPARE return code and VAR statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646975#M193582</link>
      <description>&lt;P&gt;By nor specifying VAR, you request that SAS compare all variables that can be found.&lt;/P&gt;
&lt;P&gt;No list means no restriction: everything is compared.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 06:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-COMPARE-return-code-and-VAR-statement/m-p/646975#M193582</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-12T06:33:26Z</dc:date>
    </item>
  </channel>
</rss>

