<?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 Warning &amp;quot;variables already exit&amp;quot; when merging two datasets by proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/670374#M201226</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;When try to merge two dataset that has some distinct Type in common, I face the problem with the result. even try too out at the log file, I also cannot find where the error comes from. I am wondering if you can have a look and give me a suggestion or else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the dataset final (called a).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 412px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47263i0ED09E0B43756CB6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And I have another raw dataset (called have)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="b.PNG" style="width: 718px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47265i8B73379EFFE106F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="b.PNG" alt="b.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;What I want is to match observation in raw data (dataset have) associated with the dataset final based on "Type" and "year" of the dataset final as below (we call dataset want):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="c.PNG" style="width: 991px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47288iD656E191166F24C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="c.PNG" alt="c.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;By doing this, I use the code as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=final;
by Type;
run;

proc sort data=have;
by Type;
run;

proc sql;
create Table want as
select a.*,b.*
from final as a, have as b
where (a.Type = b.Type and a.year=b.year);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the results as the picture above, but when I check the log, it shows two warnings like that, I am wondering if there is anything wrong in my code or there is anything that I did not concern enough.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc sql;
101        create Table merge_ as
102        select a.*,b.*
103        from step4 as a, merge_9_10 as b
104        where (a.Type = b.Type and a.year=b.year);
WARNING: Variable Type already exists on file WORK.MERGE_.
WARNING: Variable year already exists on file WORK.MERGE_.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Sat, 18 Jul 2020 20:01:59 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2020-07-18T20:01:59Z</dc:date>
    <item>
      <title>Warning "variables already exit" when merging two datasets by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/670374#M201226</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;When try to merge two dataset that has some distinct Type in common, I face the problem with the result. even try too out at the log file, I also cannot find where the error comes from. I am wondering if you can have a look and give me a suggestion or else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the dataset final (called a).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 412px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47263i0ED09E0B43756CB6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And I have another raw dataset (called have)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="b.PNG" style="width: 718px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47265i8B73379EFFE106F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="b.PNG" alt="b.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;What I want is to match observation in raw data (dataset have) associated with the dataset final based on "Type" and "year" of the dataset final as below (we call dataset want):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="c.PNG" style="width: 991px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47288iD656E191166F24C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="c.PNG" alt="c.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;By doing this, I use the code as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=final;
by Type;
run;

proc sort data=have;
by Type;
run;

proc sql;
create Table want as
select a.*,b.*
from final as a, have as b
where (a.Type = b.Type and a.year=b.year);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the results as the picture above, but when I check the log, it shows two warnings like that, I am wondering if there is anything wrong in my code or there is anything that I did not concern enough.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc sql;
101        create Table merge_ as
102        select a.*,b.*
103        from step4 as a, merge_9_10 as b
104        where (a.Type = b.Type and a.year=b.year);
WARNING: Variable Type already exists on file WORK.MERGE_.
WARNING: Variable year already exists on file WORK.MERGE_.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 18 Jul 2020 20:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/670374#M201226</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2020-07-18T20:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Warning "variables already exit" when merging two datasets by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/670375#M201227</link>
      <description>&lt;P&gt;I believe the WARNING in the log is because you used&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select a.*,b.*&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the WARNING&amp;nbsp; correctly tells you that both TYPE and YEAR exist in both data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The WARNING would go away if you used&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select a.*,b.isin,b.secd,b.geogn,...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(you can type the rest of the variable names except year)&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 20:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/670375#M201227</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-18T20:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Warning "variables already exit" when merging two datasets by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/670377#M201229</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13573"&gt;@Paige&lt;/a&gt; Miller, it works for me now!</description>
      <pubDate>Sat, 18 Jul 2020 20:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/670377#M201229</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2020-07-18T20:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Warning "variables already exit" when merging two datasets by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/790800#M253208</link>
      <description>&lt;P&gt;any way to remove this warning?!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 03:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Warning-quot-variables-already-exit-quot-when-merging-two/m-p/790800#M253208</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-19T03:54:47Z</dc:date>
    </item>
  </channel>
</rss>

