<?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: Merge two datasets without common variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231564#M42146</link>
    <description>You are the most experienced man I have ever seen. Thank you, so nice of you !</description>
    <pubDate>Sun, 25 Oct 2015 22:45:40 GMT</pubDate>
    <dc:creator>DingDing</dc:creator>
    <dc:date>2015-10-25T22:45:40Z</dc:date>
    <item>
      <title>Merge two datasets without common variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231557#M42142</link>
      <description>&lt;P&gt;I want to merge two datasets &amp;nbsp;the&amp;nbsp;variable in dataset 1is IATA and in dataset2 is&amp;nbsp;&lt;SPAN&gt;UNIQUE_CARRIER. In the output, I want to remove the obserbations that&amp;nbsp;"IATA" does'not have. Generally I know use the "PROC merge" like that. but it seems it only works when they have common variable. I don't know how to do if they don't have common name of a variable. could anybody give me some instructions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA  dataset3;
MERGE dataset1 (IN=a) 
dataset2 (IN=b );
By common_variable
IF a=1;
RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;one is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IATA &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B1 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;OO &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;QU &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UNIQUE_CARRIER &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AA&lt;/P&gt;&lt;P&gt;AA&lt;/P&gt;&lt;P&gt;B1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OO &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;QU &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2015 21:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231557#M42142</guid>
      <dc:creator>DingDing</dc:creator>
      <dc:date>2015-10-25T21:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two datasets without common variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231560#M42143</link>
      <description>&lt;P&gt;Rename the key variable for the merge as shown below and it should take care of your problem.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA IATA  ;
 INPUT IATA:$2.;
DATALINES;
B1      
OO     
QU      
;
RUN;
DATA UNIQUE_CARRIER ;
 INPUT UNIQUE_CARRIER:$2.;
DATALINES; 
AA
AA
B1                               
OO                              
QU  
;
RUN;
PROC SORT DATA=IATA;
  BY IATA;
RUN;
PROC SORT DATA=UNIQUE_CARRIER(RENAME=UNIQUE_CARRIER=IATA);
  BY IATA;
RUN;
DATA NEW_IATA;
     MERGE IATA(IN=A)
           UNIQUE_CARRIER(IN=B);
        BY IATA;
     IF A;
RUN;
PROC PRINT;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output it generates is here for your reference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Obs	IATA
1	B1
2	OO
3	QU&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2015 22:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231560#M42143</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-10-25T22:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two datasets without common variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231561#M42144</link>
      <description>&lt;P&gt;I should have mentioned that the rename is in the sort step in my code above&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2015 22:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231561#M42144</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-10-25T22:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two datasets without common variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231564#M42146</link>
      <description>You are the most experienced man I have ever seen. Thank you, so nice of you !</description>
      <pubDate>Sun, 25 Oct 2015 22:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231564#M42146</guid>
      <dc:creator>DingDing</dc:creator>
      <dc:date>2015-10-25T22:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two datasets without common variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231565#M42147</link>
      <description>&lt;P&gt;Thanks for your kind words. I'm learning too. There are much more&amp;nbsp;knowledgeable and experienced experts in this forum, you'll notice. &amp;nbsp;Not to mention, there are employees of SAS as well, you are here to help us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck and have fun with SAS DingDing.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2015 22:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets-without-common-variable/m-p/231565#M42147</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-10-25T22:48:31Z</dc:date>
    </item>
  </channel>
</rss>

