<?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: Merging sas data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705716#M216536</link>
    <description>&lt;P&gt;Try hash.&lt;/P&gt;
&lt;P&gt;Please send data not in a picture but as a sas code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  infile datalines dlm="09"x;
	input x y;
datalines;
1	10
1	11
1	15
2	34
2	30
3	40
;
run;

data two;
  infile datalines dlm="09"x;
	input x z;
datalines;
1	100
2	150
3	300
;
run;

data three;
	if _N_=1 then do;
		if 0 then set one;
		dcl hash h(dataset:"one",multidata:"y");
		h.definekey("x");
		h.definedata("y");
		h.definedone();
	end;
	set two;
	do while(h.do_over()=0);
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 14 Dec 2020 14:39:53 GMT</pubDate>
    <dc:creator>hhinohar</dc:creator>
    <dc:date>2020-12-14T14:39:53Z</dc:date>
    <item>
      <title>Merging sas data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705712#M216533</link>
      <description>&lt;P&gt;Hello guys.&lt;BR /&gt;I need to merge these 2 sets to get the below result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dritan007_0-1607955921770.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52594i6E74DCCA73A5BCD0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dritan007_0-1607955921770.png" alt="Dritan007_0-1607955921770.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dritan007_1-1607955948512.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52595i2FEBF9754CEB03D2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dritan007_1-1607955948512.png" alt="Dritan007_1-1607955948512.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dritan007_2-1607955997013.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52597iC00F9DB60AB7EEA7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dritan007_2-1607955997013.png" alt="Dritan007_2-1607955997013.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The result I want is in third table but I can not get it with merge statement?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 14:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705712#M216533</guid>
      <dc:creator>Dritan007</dc:creator>
      <dc:date>2020-12-14T14:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Merging sas data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705716#M216536</link>
      <description>&lt;P&gt;Try hash.&lt;/P&gt;
&lt;P&gt;Please send data not in a picture but as a sas code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  infile datalines dlm="09"x;
	input x y;
datalines;
1	10
1	11
1	15
2	34
2	30
3	40
;
run;

data two;
  infile datalines dlm="09"x;
	input x z;
datalines;
1	100
2	150
3	300
;
run;

data three;
	if _N_=1 then do;
		if 0 then set one;
		dcl hash h(dataset:"one",multidata:"y");
		h.definekey("x");
		h.definedata("y");
		h.definedone();
	end;
	set two;
	do while(h.do_over()=0);
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Dec 2020 14:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705716#M216536</guid>
      <dc:creator>hhinohar</dc:creator>
      <dc:date>2020-12-14T14:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Merging sas data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705720#M216539</link>
      <description>&lt;P&gt;MERGE is exactly the right thing to do.&amp;nbsp; You are probably forgetting to add a BY statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   merge top_dataset bottom_dataset;
   by x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Dec 2020 14:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705720#M216539</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-12-14T14:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Merging sas data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705736#M216549</link>
      <description>&lt;P&gt;Merge works fine for me&lt;/P&gt;
&lt;PRE&gt;data one;
	input x y;
datalines;
1	10
1	11
1	15
2	34
2	30
3	40
;
run;

data two;
	input x z;
datalines;
1	100
2	150
3	300
;
run;

data want;
  merge one two;
  by x;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;However, &lt;/STRONG&gt;if your actual data has multiple records with the same By value in both data sets the log will say so and the merge is likely not what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say something like "but I can not get it with merge statement" you should include the code you tried. Sometimes you may be close, sometimes using the wrong approach entirely. Making us guess what you may have tried is like pulling hen's teeth.&lt;/P&gt;
&lt;P&gt;Best is to show us the code used by copying from your log the entire procedure or data step code will all the associated notes, warnings or other messages and then pasting into a text box opened on the forum with the &amp;lt;/&amp;gt; icon to preserve formatting.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 15:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-sas-data-sets/m-p/705736#M216549</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-14T15:38:21Z</dc:date>
    </item>
  </channel>
</rss>

