<?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: Question about SAS merge function in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Question-about-SAS-merge-function/m-p/517783#M3413</link>
    <description>&lt;P&gt;The&amp;nbsp;&lt;EM&gt;size&lt;/EM&gt; (and other attributes) will be set from the first variable encountered during the compilation phase, but the&amp;nbsp;&lt;EM&gt;contents&lt;/EM&gt; will be from the last record read during the execution phase.&lt;/P&gt;</description>
    <pubDate>Sun, 02 Dec 2018 00:09:33 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-12-02T00:09:33Z</dc:date>
    <item>
      <title>Question about SAS merge function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-SAS-merge-function/m-p/517773#M3407</link>
      <description>&lt;P&gt;On the merge function, looking the on-line documentation (&lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001318494.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001318494.htm&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;There is a description when two records are merged, and one field has the same name.&amp;nbsp; The documentation indicates the last record read will be the value in the merged record.&lt;/P&gt;&lt;P&gt;(from the website)&lt;/P&gt;&lt;P&gt;If you do not use the RENAME= option and a variable exists in more than one data set, then the value of that variable in the last data set read is the value that goes into the result record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question: is there ever a time when the field in the first record will ever be the value in the result record?&lt;/P&gt;&lt;P&gt;IE:&lt;/P&gt;&lt;P&gt;Record1: field expressn (size char(4)), description code&lt;/P&gt;&lt;P&gt;Record2: field expressn (size char(1)), express (value x or space)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data merge_record;&lt;/P&gt;&lt;P&gt;Merge (record1, record2)&lt;/P&gt;&lt;P&gt;On fields a, b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would merge_record.expressn ever be size char(4) – descriptive code?&amp;nbsp; As I understand the on-line documentation, the merge_record.expressn will always be size char(1) – express (value x or space).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2018 23:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-SAS-merge-function/m-p/517773#M3407</guid>
      <dc:creator>mv_fes</dc:creator>
      <dc:date>2018-12-01T23:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Question about SAS merge function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-SAS-merge-function/m-p/517783#M3413</link>
      <description>&lt;P&gt;The&amp;nbsp;&lt;EM&gt;size&lt;/EM&gt; (and other attributes) will be set from the first variable encountered during the compilation phase, but the&amp;nbsp;&lt;EM&gt;contents&lt;/EM&gt; will be from the last record read during the execution phase.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2018 00:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-SAS-merge-function/m-p/517783#M3413</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-02T00:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Question about SAS merge function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-SAS-merge-function/m-p/517789#M3418</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;explained, the definition of the new variable will be $4.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some cases that illustrate this concept of "last record read" when merging by a b:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;When there is a 1 to 1 match, the value read comes from the second data set and thus will always be no more than 1 character long.&lt;/LI&gt;
&lt;LI&gt;When there is a 1 to many match (many observations in Record 2 for the same a b combination), again the last value read comes from the second data set and thus will always be no more than 1 character long.&lt;/LI&gt;
&lt;LI&gt;When there is a mismatch and the a b combination does not appear in the second data set, the last record read comes from the first data set and can be up to 4 characters long.&lt;/LI&gt;
&lt;LI&gt;The tricky case:&amp;nbsp; when there is a many to 1 match (multiple observations for the a b combination from the first data set, but just one observation in the second data set), here's what results for that a b combination.&amp;nbsp; For the first observation, the value comes from the second data set (1 character at most).&amp;nbsp; For all the remaining observations in that a b combination, the last value comes from the first data set and will be up to 4 characters long.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's trickier than it looks, and is based on the idea that SAS never re-reads an observation.&amp;nbsp; It just keeps whatever it read last.&amp;nbsp; You should probably create a few test data sets to try it out and see what you get.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2018 01:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-SAS-merge-function/m-p/517789#M3418</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-02T01:11:18Z</dc:date>
    </item>
  </channel>
</rss>

