<?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 keeping only some variables of one dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783682#M249955</link>
    <description>&lt;P&gt;Since you are only keeping records that have matching values of N in the data set MO the most likely cause of "missing" values for those variables is that your data set TE does not have values when the N matches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can test this with:&lt;/P&gt;
&lt;PRE&gt;Proc freq data=TE;
   tables n * (UltMes MesSEMReg) /list missing;
run;&lt;/PRE&gt;
&lt;P&gt;and look at the values of N in the MO data set and see what you have for UltMes and Messemreg for those in TE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next most likely&lt;/P&gt;</description>
    <pubDate>Thu, 02 Dec 2021 15:59:48 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-12-02T15:59:48Z</dc:date>
    <item>
      <title>Merge keeping only some variables of one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783677#M249951</link>
      <description>&lt;P&gt;I'm trying to merge two different datasets, keeping some variables of the second dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data = MO;
by n;
run;
proc sort data = TE;
by n;
run;

Data MOTE; 
Merge   MO (in=A) TE (in=B keep = n UltMes MesSEMReg);
		by n;
		If A;
		run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the merged data set the variables&amp;nbsp;UltMes MesSEMReg exist but they are empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you help me solving this problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 15:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783677#M249951</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2021-12-02T15:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Merge keeping only some variables of one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783682#M249955</link>
      <description>&lt;P&gt;Since you are only keeping records that have matching values of N in the data set MO the most likely cause of "missing" values for those variables is that your data set TE does not have values when the N matches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can test this with:&lt;/P&gt;
&lt;PRE&gt;Proc freq data=TE;
   tables n * (UltMes MesSEMReg) /list missing;
run;&lt;/PRE&gt;
&lt;P&gt;and look at the values of N in the MO data set and see what you have for UltMes and Messemreg for those in TE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next most likely&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 15:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783682#M249955</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-02T15:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merge keeping only some variables of one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783684#M249956</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both variables&amp;nbsp;&lt;EM&gt;UltMes&lt;/EM&gt; and&amp;nbsp; &lt;EM&gt;MesSEMReg&lt;/EM&gt; of dataset TE have registers in all of the fields.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is not that one you helpfully suggested.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 16:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783684#M249956</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2021-12-02T16:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merge keeping only some variables of one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783698#M249968</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/369095"&gt;@ramgouveia&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both variables&amp;nbsp;&lt;EM&gt;UltMes&lt;/EM&gt; and&amp;nbsp; &lt;EM&gt;MesSEMReg&lt;/EM&gt; of dataset TE have registers in all of the fields.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is not that one you helpfully suggested.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you sure that you have any matches of the BY variable? The code you used would have no contribution from TE if there are no matching values of N.&lt;/P&gt;
&lt;P&gt;Did you 1) actually run the Proc Freq code I suggested and 2) compare any of the N values from the Freq output with the MO data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just looking at displayed values may not be sufficient. Formats can round values to appear the same and if N is character leading spaces or non-printable characters may be present that make them not equal.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 17:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783698#M249968</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-02T17:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merge keeping only some variables of one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783700#M249969</link>
      <description>&lt;P&gt;By any chance, do these variables:&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;n UltMes MesSEMReg&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;already exist in the TO data set before you merge?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 17:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783700#M249969</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-12-02T17:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Merge keeping only some variables of one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783867#M250054</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have misspecified the name of the second dataset. Correcting it, solves the error.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 09:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-keeping-only-some-variables-of-one-dataset/m-p/783867#M250054</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2021-12-03T09:44:02Z</dc:date>
    </item>
  </channel>
</rss>

