<?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: Inner Join with different column names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Inner-Join-with-different-column-names/m-p/604468#M175259</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/298747"&gt;@pw7632&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table&amp;nbsp; baseball as&lt;BR /&gt;select a.Name , a.dob , a.gender , b.name, b.start, b.end&lt;/P&gt;
&lt;P&gt;from salaries b inner join&lt;BR /&gt;TMP2.players a&lt;BR /&gt;on a.name = b.name;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset that have the same values but different column names.&amp;nbsp;a.Name , a.dob , a.gender all have different column names. How do I change them to make them the same as the b table? I also want the common variable to be name to join them.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A SAS dataset&amp;nbsp; cannot have two variable with the same name.&amp;nbsp; So in your example code the second variable named NAME is not going to be written.&amp;nbsp; Just provide new name in the select statement.&amp;nbsp; There is no need for two copies of NAME since your join is requiring them to be the same value.&amp;nbsp; But if both dataset had DOB and GENDER for example you could select both and rename one of them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table&amp;nbsp;baseball as
 select a.Name 
      , a.dob 
      , a.gender 
      , b.dob as dob2
      , b.gender as gender2
      , b.start
      , b.end
 from salaries b
   inner join TMP2.players a
   on a.name = b.name
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 15 Nov 2019 14:22:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-15T14:22:11Z</dc:date>
    <item>
      <title>Inner Join with different column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inner-Join-with-different-column-names/m-p/604465#M175258</link>
      <description>&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table&amp;nbsp; baseball as&lt;BR /&gt;select a.Name , a.dob , a.gender , b.name, b.start, b.end&lt;/P&gt;&lt;P&gt;from salaries b inner join&lt;BR /&gt;TMP2.players a&lt;BR /&gt;on a.name = b.name;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that have the same values but different column names.&amp;nbsp;a.Name , a.dob , a.gender all have different column names. How do I change them to make them the same as the b table? I also want the common variable to be name to join them.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 14:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inner-Join-with-different-column-names/m-p/604465#M175258</guid>
      <dc:creator>pw7632</dc:creator>
      <dc:date>2019-11-15T14:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with different column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inner-Join-with-different-column-names/m-p/604468#M175259</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/298747"&gt;@pw7632&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table&amp;nbsp; baseball as&lt;BR /&gt;select a.Name , a.dob , a.gender , b.name, b.start, b.end&lt;/P&gt;
&lt;P&gt;from salaries b inner join&lt;BR /&gt;TMP2.players a&lt;BR /&gt;on a.name = b.name;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset that have the same values but different column names.&amp;nbsp;a.Name , a.dob , a.gender all have different column names. How do I change them to make them the same as the b table? I also want the common variable to be name to join them.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A SAS dataset&amp;nbsp; cannot have two variable with the same name.&amp;nbsp; So in your example code the second variable named NAME is not going to be written.&amp;nbsp; Just provide new name in the select statement.&amp;nbsp; There is no need for two copies of NAME since your join is requiring them to be the same value.&amp;nbsp; But if both dataset had DOB and GENDER for example you could select both and rename one of them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table&amp;nbsp;baseball as
 select a.Name 
      , a.dob 
      , a.gender 
      , b.dob as dob2
      , b.gender as gender2
      , b.start
      , b.end
 from salaries b
   inner join TMP2.players a
   on a.name = b.name
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Nov 2019 14:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inner-Join-with-different-column-names/m-p/604468#M175259</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-15T14:22:11Z</dc:date>
    </item>
  </channel>
</rss>

