<?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: When merging two data sets by a variable why all OBS not populated with values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330188#M74007</link>
    <description>&lt;P&gt;The results you are getting would typically occur if your second data set also contained VAL (or is it VALUE?), but with all missing values.&amp;nbsp; To get rid of it, you can drop it as late as on the MERGE statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge data2 (in=a drop=val) data1;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if a;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Feb 2017 14:25:47 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-02-06T14:25:47Z</dc:date>
    <item>
      <title>When merging two data sets by a variable why all OBS not populated with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330107#M73985</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am merging two datasets. why only first OBS is populated in my output data. &amp;nbsp;Please help. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;P&gt;data data3;&lt;BR /&gt;merge data2(in=a) data1(in=b);&lt;BR /&gt;by id;&lt;BR /&gt;if a;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data1&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp;value&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data2&lt;/P&gt;&lt;P&gt;id&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output getting;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp;val&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;output needed;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp;val&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;10&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;20&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 07:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330107#M73985</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-02-06T07:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: When merging two data sets by a variable why all OBS not populated with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330109#M73986</link>
      <description>Not thought about this consequence when using the if a; concept. &lt;BR /&gt;Not tested but my theory is that for observation 2 there is no corresponding observation in b: hence the missing value.&lt;BR /&gt;Regardless I think a simple SQL inner join is better in this situation.</description>
      <pubDate>Mon, 06 Feb 2017 07:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330109#M73986</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-02-06T07:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: When merging two data sets by a variable why all OBS not populated with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330116#M73988</link>
      <description>&lt;P&gt;I'm using SAS 9.4 with SAS UE on linux.&lt;/P&gt;
&lt;P&gt;Attached is the code and result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is a copy of your (&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/68272"&gt;@knveraraju91&lt;/a&gt;&amp;nbsp;) post, addaptedf to create test data.&lt;/P&gt;
&lt;P&gt;The result is as you wanted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check your log and code again. It should work.&lt;/P&gt;
&lt;P&gt;If not - what SAS version and platform you use ?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 08:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330116#M73988</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-06T08:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: When merging two data sets by a variable why all OBS not populated with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330126#M73993</link>
      <description>&lt;P&gt;Are you sure that data2 only contains the variable id?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the output of proc contents for both datasets.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 10:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330126#M73993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-06T10:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: When merging two data sets by a variable why all OBS not populated with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330188#M74007</link>
      <description>&lt;P&gt;The results you are getting would typically occur if your second data set also contained VAL (or is it VALUE?), but with all missing values.&amp;nbsp; To get rid of it, you can drop it as late as on the MERGE statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge data2 (in=a drop=val) data1;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if a;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 14:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-merging-two-data-sets-by-a-variable-why-all-OBS-not/m-p/330188#M74007</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-06T14:25:47Z</dc:date>
    </item>
  </channel>
</rss>

