<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801778#M315570</link>
    <description>&lt;P&gt;thanks, I tried but they are not merging..&lt;/P&gt;
&lt;P&gt;anyway what does it mean to merge by two variables?&lt;/P&gt;</description>
    <pubDate>Sat, 12 Mar 2022 05:53:57 GMT</pubDate>
    <dc:creator>HeatherNewton</dc:creator>
    <dc:date>2022-03-12T05:53:57Z</dc:date>
    <item>
      <title>merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801281#M315343</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data fruit;
  input up down sub_product fav $;
datalines;
2 5	apple	applepie
3 2 lemon	lemontart
4 0 melon	melonmilk
7 11 lemon	lemontart
19 33 apple	applejuice
run;

data box;
input up down anyy okok $;
3 6	app	appl
5 9 lem	lemo
4 0 mel	melilk
7 11 lem	lemotrt
21 33 appl	appleju


data new;
merge fruit box;
by up down;
&lt;/PRE&gt;
&lt;P&gt;I am merging two data sets by two variables how can I write it in terms of sql? should I use full join?&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 10:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801281#M315343</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-10T10:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801292#M315344</link>
      <description>&lt;P&gt;I had to fix BOTH of your DATA steps. Please test your code before posting it, so we don't have to do it for you. See it as basic courtesy with regards to those who are intended to help you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fruit;
input up down sub_product $ fav $;
datalines;
2 5 apple applepie
3 2 lemon lemontart
4 0 melon melonmilk
7 11 lemon lemontart
19 33 apple applejuice
;

data box;
input up down anyy $ okok $;
datalines;
3 6 app appl
5 9 lem lemo
4 0 mel melilk
7 11 lem lemotrt
21 33 appl appleju
;

proc sql;
create table want as
  select
    coalesce(t1.up,t2.up) as up,
    coalesce(t1.down,t2.down) as down,
    t1.sub_product,
    t1.fav,
    t2.anyy,
    t2.okok
  from fruit t1 full join box t2
  on t1.up = t2.up and t1.down = t2.down
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But always keep in mind that SQL behaves differently from a data step when you have a many-to-many relationship.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 11:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801292#M315344</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-10T11:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801778#M315570</link>
      <description>&lt;P&gt;thanks, I tried but they are not merging..&lt;/P&gt;
&lt;P&gt;anyway what does it mean to merge by two variables?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 05:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801778#M315570</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-12T05:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801780#M315571</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HeatherNewton_0-1647064818378.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69417i1569F7718A1A9898/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HeatherNewton_0-1647064818378.png" alt="HeatherNewton_0-1647064818378.png" /&gt;&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;seem missing something.. fav column is showing okok&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 06:00:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801780#M315571</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-12T06:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801781#M315572</link>
      <description>&lt;P&gt;Your result does not show column okok, and it has less observations than mine.&lt;/P&gt;
&lt;P&gt;Post the whole code you ran.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 06:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801781#M315572</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-12T06:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801783#M315573</link>
      <description>&lt;PRE&gt;data fruit;
input up down sub_product $ fav $;
datalines;
2 5 apple applepie
3 2 lemon lemontart
4 0 melon melonmilk
7 11 lemon lemontart
19 33 apple applejuice
;

proc sort data=fruit;
run;

data box;
input up down anyy $ okok $;
datalines;
3 6 app appl
5 9 lem lemo
4 0 mel melilk
7 11 lem lemotrt
21 33 appl appleju
;

proc sort data=box;
run;
proc sql;
create table want as
  select
    coalesce(t1.up,t2.up) as up,
    coalesce(t1.down,t2.down) as down,
    t1.sub_product,
    t1.fav,
    t2.anyy,
    t2.okok
  from fruit t1 full join box t2
  on t1.up = t2.up and t1.down = t2.down
;
quit;&lt;/PRE&gt;
&lt;P&gt;results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HeatherNewton_0-1647067477216.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69418i5B39E6A72DAFA375/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HeatherNewton_0-1647067477216.png" alt="HeatherNewton_0-1647067477216.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;here you go...&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 06:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801783#M315573</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-12T06:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801784#M315574</link>
      <description>&lt;P&gt;Your picture shows incoming dataset fruit, not the resulting table want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS to view the correct dataset, use the drop-down of the Output tab.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 07:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801784#M315574</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-12T07:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801789#M315576</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HeatherNewton_0-1647070120259.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69419iF382026FB3BF248B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HeatherNewton_0-1647070120259.png" alt="HeatherNewton_0-1647070120259.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;thanks I now get it the above in results, but what I get from output is the below which is a mixture of two tables if we look at the what is circled.. and also why the table is displayed in output, supposed all data set will show in output?&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="HeatherNewton_1-1647070278979.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69420i138B50D0B2A66083/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HeatherNewton_1-1647070278979.png" alt="HeatherNewton_1-1647070278979.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 07:31:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801789#M315576</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-12T07:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801792#M315579</link>
      <description>&lt;P&gt;Your second picture shows the table view of the fruit dataset. The first looks like a PROC PRINT of dataset want, which is shown in the Results tab.&lt;/P&gt;
&lt;P&gt;You must select the WANT dataset in the table viewer (since all three datasets were created during a single submit, all will show up there).&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 07:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge/m-p/801792#M315579</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-12T07:58:25Z</dc:date>
    </item>
  </channel>
</rss>

