<?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: proc sql question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294743#M61508</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have the answer but it seems that "a" has a special meaning in a subquery context. Indeed, if you replace&lt;/P&gt;
&lt;P&gt;a with, for instance, ab in your request, the error shows up as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as
    select * from have
    where a in (select ab from have1)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ERROR: The following columns were not found in the contributing tables: ab.&lt;BR /&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Other tests ;&lt;/P&gt;
&lt;P&gt;Direct query&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select a from have1 =&amp;gt; Error message &lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Use of an existing table&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    create table want as
    select * from have
    where a in (select a from sashelp.cars)
 =&amp;gt; No error message&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Aug 2016 10:22:44 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2016-08-29T10:22:44Z</dc:date>
    <item>
      <title>proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294737#M61504</link>
      <description>&lt;P&gt;Hello SAS Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get all records from dataset have which are not in dataset have1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;a='A';output;&lt;BR /&gt;a='B';output;&lt;BR /&gt;a='C';output;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data have1;&lt;BR /&gt;b='E';output;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;create table want as&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;select * from have&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;where a not in (select a from have1);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering why there is no error message with "ERROR: Column a could not be found in the table/view identified with the correlation name have1."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i change my code like this,i get the error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;create table want as&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;select * from have x&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;where a not in (select y.a from have1 y);&lt;BR /&gt;quit;&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;Thank you for helping,&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 09:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294737#M61504</guid>
      <dc:creator>aurel_hogea</dc:creator>
      <dc:date>2016-08-29T09:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294738#M61505</link>
      <description>In your sample the only column in have1 is b, not a.</description>
      <pubDate>Mon, 29 Aug 2016 09:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294738#M61505</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-08-29T09:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294739#M61506</link>
      <description>&lt;P&gt;Yes, that's right. Precisely for this i'm wondering why no error message.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 10:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294739#M61506</guid>
      <dc:creator>aurel_hogea</dc:creator>
      <dc:date>2016-08-29T10:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294743#M61508</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have the answer but it seems that "a" has a special meaning in a subquery context. Indeed, if you replace&lt;/P&gt;
&lt;P&gt;a with, for instance, ab in your request, the error shows up as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as
    select * from have
    where a in (select ab from have1)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ERROR: The following columns were not found in the contributing tables: ab.&lt;BR /&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Other tests ;&lt;/P&gt;
&lt;P&gt;Direct query&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select a from have1 =&amp;gt; Error message &lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Use of an existing table&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    create table want as
    select * from have
    where a in (select a from sashelp.cars)
 =&amp;gt; No error message&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 10:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294743#M61508</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2016-08-29T10:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294745#M61510</link>
      <description>&lt;P&gt;Without the alias SAS searches for a variable a in ANY table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not the behaviour you'd expect unfortunately.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 10:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294745#M61510</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-29T10:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294756#M61519</link>
      <description>&lt;P&gt;Thank you very much for your answers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 11:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294756#M61519</guid>
      <dc:creator>aurel_hogea</dc:creator>
      <dc:date>2016-08-29T11:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294798#M61536</link>
      <description>&lt;P&gt;Do you have any idea of why it is so ?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 13:13:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-question/m-p/294798#M61536</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2016-08-29T13:13:28Z</dc:date>
    </item>
  </channel>
</rss>

