<?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: WARNING MESSAGES in PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167946#M263969</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will receive a message, because you have variables with the same name in both tables and you should tell the system within your SQL, which variable should be selected.&lt;/P&gt;&lt;P&gt;So "select a.bank, ..." instead of "select bank, ..." or "select *..." is more clean.&lt;/P&gt;&lt;P&gt;However the statement will work more less flawless and SAS will take the column (variable) from the table that you stated first in your "from" statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The deal with your statement is that you have an "order by" within your SQL. You also need to tell SAS by which column it should sort the output data.&lt;/P&gt;&lt;P&gt;That is exaclty the Message you receive by now:&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #339966;"&gt;WARNING: Column named BANK is duplicated in a select expression (or a view).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Explicit references to it will be to the first one.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So "...order by a.bank..." is more clean than "...order by bank ...".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The log tells you that "explicit references" will refer to the first one. That means from the first table in the "From"-statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Order By bank" is an explicit reference and you should really explicitly declare which column is meant.&lt;/P&gt;&lt;P&gt;"select *" is not an explicit reference, however the code is cleaner if you state which columns you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Jan 2015 14:11:39 GMT</pubDate>
    <dc:creator>mfab</dc:creator>
    <dc:date>2015-01-05T14:11:39Z</dc:date>
    <item>
      <title>WARNING MESSAGES in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167943#M263966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Need help correcting code to eliminate these WARNING MESSAGES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table work.obgtick4 as&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct *&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from work.obgtick3 A&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inner join daily_obln_table&amp;nbsp; b&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.bank = b.bank and a.obligor = b.obligor and a.obligation =&lt;BR /&gt;! b.obligation&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER BY SORT_LOB, DIVISION_NAME, RM_LOB, ASSN, OFFICER_NAME, CONT,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BANK, OBLIGOR, OBLIGATION ;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;WARNING: Column named BANK is duplicated in a select expression (or a view).&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Explicit references to it will be to the first one.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;WARNING: Column named OBLIGOR is duplicated in a select expression (or a&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view). Explicit references to it will be to the first one.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;WARNING: Column named OBLIGATION is duplicated in a select expression (or a&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view). Explicit references to it will be to the first one.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;WARNING: Variable bank already exists on file WORK.OBGTICK4.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;WARNING: Variable obligor already exists on file WORK.OBGTICK4.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #339966;"&gt;WARNING: Variable obligation already exists on file WORK.OBGTICK4.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG style="color: #0000ff;"&gt;NOTE: Table WORK.OBGTICK4 created, with 2160 rows and 338 columns.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;quit ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG style="color: #0000ff;"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.81 seconds&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.42 seconds&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 20:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167943#M263966</guid>
      <dc:creator>chandler</dc:creator>
      <dc:date>2015-01-02T20:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: WARNING MESSAGES in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167944#M263967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is because same variable names are being referred more than once in select statement. If some of the variables are appearing in multiple tables just use table alias to refer them in select statement. Something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select A.bank, b.obligor.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 21:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167944#M263967</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-01-02T21:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: WARNING MESSAGES in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167945#M263968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;This occurs because you have the variable BANK in both tables but your select is selecting all variables from both tables, so you now have two variables named BANK, even though you've specified they need to be equal in the query. SAS/SQL isn't smart enough to distinguish this &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Add the keyword FEEDBACK to your initial PROC SQL statement. Check the log, it will have the query fully expanded for you, including the alias selection. Then you can remove the duplicates as specified in the warning messages. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql FEEDBACK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table work.obgtick4 as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from work.obgtick3 A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inner join daily_obln_table&amp;nbsp; b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.bank = b.bank and a.obligor = b.obligor and a.obligation =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;! b.obligation&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER BY SORT_LOB, DIVISION_NAME, RM_LOB, ASSN, OFFICER_NAME, CONT,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BANK, OBLIGOR, OBLIGATION ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 22:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167945#M263968</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-02T22:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: WARNING MESSAGES in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167946#M263969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will receive a message, because you have variables with the same name in both tables and you should tell the system within your SQL, which variable should be selected.&lt;/P&gt;&lt;P&gt;So "select a.bank, ..." instead of "select bank, ..." or "select *..." is more clean.&lt;/P&gt;&lt;P&gt;However the statement will work more less flawless and SAS will take the column (variable) from the table that you stated first in your "from" statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The deal with your statement is that you have an "order by" within your SQL. You also need to tell SAS by which column it should sort the output data.&lt;/P&gt;&lt;P&gt;That is exaclty the Message you receive by now:&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #339966;"&gt;WARNING: Column named BANK is duplicated in a select expression (or a view).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Explicit references to it will be to the first one.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So "...order by a.bank..." is more clean than "...order by bank ...".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The log tells you that "explicit references" will refer to the first one. That means from the first table in the "From"-statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Order By bank" is an explicit reference and you should really explicitly declare which column is meant.&lt;/P&gt;&lt;P&gt;"select *" is not an explicit reference, however the code is cleaner if you state which columns you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Jan 2015 14:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-MESSAGES-in-PROC-SQL/m-p/167946#M263969</guid>
      <dc:creator>mfab</dc:creator>
      <dc:date>2015-01-05T14:11:39Z</dc:date>
    </item>
  </channel>
</rss>

