<?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: What is wrong w this SQL code? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192137#M266179</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not very familiar with SAS's Intersect operator but from your syntax it 'joins' two stand-alone Select queries, like a Union does.&amp;nbsp; Neither query has any knowledge of the other--the query with the table aliased as ball06 has no knowledge of the query with the table aliased as ball04 so your Where critieria will not work.&amp;nbsp; That's what the error message is saying.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe Tom's second answer will give you the results you want. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Mar 2014 15:29:40 GMT</pubDate>
    <dc:creator>bentleyj1</dc:creator>
    <dc:date>2014-03-04T15:29:40Z</dc:date>
    <item>
      <title>What is wrong w this SQL code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192133#M266175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is wrong with this sas code?&lt;/P&gt;&lt;P&gt;proc sql; select * from ball04&lt;/P&gt;&lt;P&gt;intersect all&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from ball06&lt;/P&gt;&lt;P&gt;where ball04.player=ball06.player;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; I get this error ERROR: Unresolved reference to table/correlation name ball04.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 04:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192133#M266175</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-03-04T04:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong w this SQL code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192134#M266176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think Proc SQL is expecting aliases to be declared&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from ball04 b4&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;intersect all&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from ball06 b6&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where b4.player=b6.player;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 12:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192134#M266176</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2014-03-04T12:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong w this SQL code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192135#M266177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are asking it to take the common rows from two sets of records with the INTERSECT keyword.&amp;nbsp; In that case the use of a where clause to also require that the subset of the variables to match is redundant. &lt;/P&gt;&lt;P&gt;Perhaps you want an inner join instead?&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;select *&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;from ball04&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; inner join &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ball06&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;on ball04.player=ball06.player&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 13:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192135#M266177</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-04T13:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong w this SQL code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192136#M266178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you want the intersection why not just take the records from one or the other table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;select *&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; from ball04&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; where exists (select * from ball06 where ball04.player=ball06.player)&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 14:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192136#M266178</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-04T14:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong w this SQL code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192137#M266179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not very familiar with SAS's Intersect operator but from your syntax it 'joins' two stand-alone Select queries, like a Union does.&amp;nbsp; Neither query has any knowledge of the other--the query with the table aliased as ball06 has no knowledge of the query with the table aliased as ball04 so your Where critieria will not work.&amp;nbsp; That's what the error message is saying.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe Tom's second answer will give you the results you want. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 15:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192137#M266179</guid>
      <dc:creator>bentleyj1</dc:creator>
      <dc:date>2014-03-04T15:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong w this SQL code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192138#M266180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is what is wrong with your SQL query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INTERSECT (as well as UNION and EXCEPT) set operators take &lt;SPAN style="text-decoration: underline;"&gt;queries&lt;/SPAN&gt; as operands. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;QUERY1&lt;/EM&gt; intersect &lt;EM&gt;QUERY2&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;finds the intersection of unique rows between &lt;EM&gt;QUERY1&lt;/EM&gt; and &lt;EM&gt;QUERY2.&lt;/EM&gt; In your case, &lt;EM&gt;QUERY2&lt;/EM&gt; is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;select * &lt;SPAN style="line-height: 1.5em;"&gt;from ball06 &lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5em;"&gt;where ball04.player=ball06.player&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which is&lt;SPAN style="text-decoration: underline;"&gt; not&lt;/SPAN&gt; a valid query since ball04 is referred to in your WHERE clause but not mentioned in your FROM clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If what you want are the players that are present in both tables, you should simply ask for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select player from ball04&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;intersect &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select player from ball06&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if you want to extract more information from ball04 or ball06, you should INNER JOIN the tables &lt;STRONG&gt;ON ball04.player=ball06.player&lt;/STRONG&gt;, as was suggested by Tom.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 18:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192138#M266180</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-03-04T18:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong w this SQL code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192139#M266181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you everyone.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 17:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-wrong-w-this-SQL-code/m-p/192139#M266181</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-03-05T17:30:38Z</dc:date>
    </item>
  </channel>
</rss>

