<?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: ERROR: Ambiguous reference, in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806378#M317691</link>
    <description>&lt;P&gt;From now on, when you get errors in the LOG, do not show us the errors detached from the code, as you have done. Please show us the ENTIRE log of the PROC SQL that has the errors. Copy as text the ENTIRE log for the PROC SQL that has the errors (every single line for this PROC) and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66123iA4EF494F9CA0F6EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" alt="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your problem is here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;group by
TOH_AGENCY,'LEVEL_DOWN 2'N,'Level 3'n, AOR_CODE;
quit;&lt;/PRE&gt;
&lt;P&gt;PROC SQL doesn't know if TOH_AGENCY is the one in data set indexed by A or in the data set indexed by B.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Apr 2022 18:53:13 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-04-06T18:53:13Z</dc:date>
    <item>
      <title>ERROR: Ambiguous reference,</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806369#M317687</link>
      <description>&lt;P&gt;hello, I am getting the following errors on the "apps_per_agent" table when I run my below proc sql. Can someone offer a suggestion on how to solve for this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Ambiguous reference, column TOH_AGENCY is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column 'LEVEL_DOWN 2'n is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column 'Level 3'n is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column AOR_CODE is in more than one table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Provides count of RTS agents based on TOH*/

proc sql; create table RTS2022_Agents as
select distinct
TOH_AGENCY,
'LEVEL_DOWN 2'N,
'Level 3'n,
AOR_CODE,
count(distinct AGENT_INDIVIDUAL_WRITING_NUMBER) as RTS_Count,
'RTS2022_Agent_Count' as index
From TOH_Data
where Role in ('Agent')
and CERTIFICATION_STATUS IN ('READY TO SELL 2022')
group by
TOH_AGENCY,'LEVEL_DOWN 2'N, 'Level 3'n, AOR_CODE,
/*having*/
calculated index
;
quit;
/*Provides count of active policies based on TOH*/

proc sql; create table Active_Count as
select distinct 
TOH_AGENCY,
count(distinct ins_plcy_id) as Active_Policies,
'Level_Down 2'n,
'Level 3'n,
aor_code
from Data_Active2 a
where cova_evnt_efcv_dt between '01Jan2022'd and today()
group by
TOH_AGENCY,'LEVEL_DOWN 2'N, 'Level 3'n, AOR_CODE;
quit;

/*Provides apps written per agent based on TOH by dividing active policies by the count of RTS agents*/

proc sql; create table Apps_Per_Agent as
select distinct 
a.TOH_Agency,
a.'LEVEL_DOWN 2'N,
a.'Level 3'n,
a.AOR_CODE,
a.RTS_Count,
b.Active_Policies,
round (Active_policies / RTS_Count,0.01) as AppsPerAgent
from RTS2022_Agents a
      inner join 
        Active_Count b
   on a.TOH_AGENCY=b.TOH_AGENCY
group by
TOH_AGENCY,'LEVEL_DOWN 2'N,'Level 3'n, AOR_CODE;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 18:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806369#M317687</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-04-06T18:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Ambiguous reference,</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806378#M317691</link>
      <description>&lt;P&gt;From now on, when you get errors in the LOG, do not show us the errors detached from the code, as you have done. Please show us the ENTIRE log of the PROC SQL that has the errors. Copy as text the ENTIRE log for the PROC SQL that has the errors (every single line for this PROC) and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66123iA4EF494F9CA0F6EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" alt="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your problem is here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;group by
TOH_AGENCY,'LEVEL_DOWN 2'N,'Level 3'n, AOR_CODE;
quit;&lt;/PRE&gt;
&lt;P&gt;PROC SQL doesn't know if TOH_AGENCY is the one in data set indexed by A or in the data set indexed by B.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 18:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806378#M317691</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-06T18:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Ambiguous reference,</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806380#M317692</link>
      <description>&lt;P&gt;Please do not separate the error messages from the code. When you do that it makes it much harder to diagnose such things. Copy from the &lt;STRONG&gt;log&lt;/STRONG&gt; the Proc SQL code &lt;STRONG&gt;and&lt;/STRONG&gt; the error message, on the forum open a text box using the &amp;lt;/&amp;gt; and paste all of the copied text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That error message will appear with the code as shown below:&lt;/P&gt;
&lt;PRE&gt;58   proc sql;
59      create table junk as
60      select name, a.sex
61      from sashelp.class as a
62           left join
63           sashelp.class as b
64           on a.name=b.name
65      ;
ERROR: Ambiguous reference, column name is in more than one table.
66   quit;

&lt;/PRE&gt;
&lt;P&gt;It means that you are using two or more data set with the same named variable and you did not specify by using an alias which specific set contributes the value you want to use.&lt;/P&gt;
&lt;P&gt;See the highlighted bit below, none of the variables show the table alias.&lt;/P&gt;
&lt;PRE&gt;proc sql; create table Apps_Per_Agent as
select distinct 
a.TOH_Agency,
a.'LEVEL_DOWN 2'N,
a.'Level 3'n,
a.AOR_CODE,
a.RTS_Count,
b.Active_Policies,
round (Active_policies / RTS_Count,0.01) as AppsPerAgent
from RTS2022_Agents a
      inner join 
        Active_Count b
   on a.TOH_AGENCY=b.TOH_AGENCY
group by
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;TOH_AGENCY,'LEVEL_DOWN 2'N,'Level 3'n, AOR_CODE;&lt;/STRONG&gt;&lt;/FONT&gt;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 18:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806380#M317692</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-06T18:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Ambiguous reference,</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806400#M317701</link>
      <description>Thank you!!</description>
      <pubDate>Wed, 06 Apr 2022 21:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Ambiguous-reference/m-p/806400#M317701</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-04-06T21:15:30Z</dc:date>
    </item>
  </channel>
</rss>

