<?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: How to prevent overwriting on a merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523189#M142137</link>
    <description>&lt;P&gt;Thank you !! I did this and with a few other steps and it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Dec 2018 21:27:51 GMT</pubDate>
    <dc:creator>Mscarboncopy</dc:creator>
    <dc:date>2018-12-21T21:27:51Z</dc:date>
    <item>
      <title>How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522970#M142034</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 data files that I am trying to merge by id.&lt;/P&gt;&lt;P&gt;Variables&amp;nbsp; from one are not in the other and it is overwriting or populating the variables.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data X;&lt;/P&gt;&lt;P&gt;Merge Y Z;&lt;/P&gt;&lt;P&gt;by ID;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variables a b and c are only in file Y&lt;/P&gt;&lt;P&gt;d e and f are only in file Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I merge them, variables a b and c repeats the values that were in file Y as if they were in file Z.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why aren't they missing ? I thought they would be missing.&lt;/P&gt;&lt;P&gt;Is there a command that I can use to make sure they remain missing if NOT IN file Z ?&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>Thu, 20 Dec 2018 22:24:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522970#M142034</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2018-12-20T22:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522971#M142035</link>
      <description>You may need to change your BY logic, if you aren't joining by ID. If the ID is the same, the same information is copied over, it is not left blank.</description>
      <pubDate>Thu, 20 Dec 2018 22:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522971#M142035</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-20T22:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522972#M142036</link>
      <description>&lt;P&gt;This makes no sense.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Y; 
  input ID A B C;
cards;
1 12 13 14
;
data Z; 
  input ID D E F;
cards;
1 22 23 24
1 32 33 34
2 1 2 3
;
data X;
  merge Y Z;
  by ID;
run;

 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.X" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;A&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;B&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;C&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;D&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;E&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;F&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;12&lt;/TD&gt;
&lt;TD class="r data"&gt;13&lt;/TD&gt;
&lt;TD class="r data"&gt;14&lt;/TD&gt;
&lt;TD class="r data"&gt;22&lt;/TD&gt;
&lt;TD class="r data"&gt;23&lt;/TD&gt;
&lt;TD class="r data"&gt;24&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;12&lt;/TD&gt;
&lt;TD class="r data"&gt;13&lt;/TD&gt;
&lt;TD class="r data"&gt;14&lt;/TD&gt;
&lt;TD class="r data"&gt;32&lt;/TD&gt;
&lt;TD class="r data"&gt;33&lt;/TD&gt;
&lt;TD class="r data"&gt;34&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No value for ABC when ID=2, since that ID is not on table Y.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 22:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522972#M142036</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-12-20T22:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522979#M142039</link>
      <description>&lt;P&gt;Show us, in a data step:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;What Y and Z look like&lt;/LI&gt;
&lt;LI&gt;What X should look like&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Help us help you.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 00:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522979#M142039</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-21T00:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522982#M142042</link>
      <description>&lt;P&gt;In the example you gave (thank you) it is ID 1 that does not have ABC not ID2 so&amp;nbsp;&lt;/P&gt;&lt;P&gt;so 12 13 14 on the second line of ID1 is the overwrite. because I am pulling 32 33 34 from another data file, and when I do so&lt;/P&gt;&lt;P&gt;ID 1 (line 2) gets 12 13 14 when it needed to be missing (like ID2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 01:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522982#M142042</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2018-12-21T01:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522983#M142043</link>
      <description>&lt;P&gt;It looks like you want&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data X;
  merge Y Z;
  by ID;
  if ^first.ID then call missing(A,B,C);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.X" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;A&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;B&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;C&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;D&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;E&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;F&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;12&lt;/TD&gt;
&lt;TD class="r data"&gt;13&lt;/TD&gt;
&lt;TD class="r data"&gt;14&lt;/TD&gt;
&lt;TD class="r data"&gt;22&lt;/TD&gt;
&lt;TD class="r data"&gt;23&lt;/TD&gt;
&lt;TD class="r data"&gt;24&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;32&lt;/TD&gt;
&lt;TD class="r data"&gt;33&lt;/TD&gt;
&lt;TD class="r data"&gt;34&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original join works as any join is supposed to though: If the key is present the data for that key is used.&lt;/P&gt;
&lt;P&gt;Clearing the data when the key is present is NOT a standard join.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 01:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522983#M142043</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-12-21T01:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522984#M142044</link>
      <description>&lt;P&gt;Y has height Body Weight variables&amp;nbsp;&lt;/P&gt;&lt;P&gt;Z has diagnoses (URI ASTHMA etc) and drugs variables&amp;nbsp;&lt;/P&gt;&lt;P&gt;X needs to have all variables from Y and Z.&lt;/P&gt;&lt;P&gt;It is also longitudinal so one ID may have 5 entries in File Y and 10 in File Z.&lt;/P&gt;&lt;P&gt;another ID might have 2 entries in File Y and 5 entries in file Z. All different ages.&lt;/P&gt;&lt;P&gt;The variable that they both have in common is AGE and I found a way to prevent the ages from overwriting. So if I have one entry from Z and 10 from Y for ID 1- I have 11 entries with different ages&amp;nbsp; for ID 1 but then all of the diagnosis that were 1 in 1 ENTRY are repeated as 1 in all other 10 entries even though it should have been 1 only in ONE ENTRY and 0 in all the other 10 (from Y). I thought they would be missing and then I could tell sas to do if dx =. then dx=0. for example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But with all diagnoses = 1 I don't have a way to give a command to transform it to 0. It will transform others (that must remain 1 to 0) - it will overwrite my correct data in Z. Every ID is different:&amp;nbsp; different ages and different amount of entries and diagnoses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 01:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522984#M142044</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2018-12-21T01:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522985#M142045</link>
      <description>&lt;P&gt;See&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;'s reply.&lt;/P&gt;
&lt;P&gt;Provide BEFORE&amp;nbsp;and AFTER sample data.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 02:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522985#M142045</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-12-21T02:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522987#M142046</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210474"&gt;@Mscarboncopy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Y has height Body Weight variables&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Z has diagnoses (URI ASTHMA etc) and drugs variables&amp;nbsp;&lt;/P&gt;
&lt;P&gt;X needs to have all variables from Y and Z.&lt;/P&gt;
&lt;P&gt;It is also longitudinal so one ID may have 5 entries in File Y and 10 in File Z.&lt;/P&gt;
&lt;P&gt;another ID might have 2 entries in File Y and 5 entries in file Z. All different ages.&lt;/P&gt;
&lt;P&gt;The variable that they both have in common is AGE and I found a way to prevent the ages from overwriting.&lt;FONT color="#800080"&gt;&lt;STRONG&gt; So if I have one entry from Z and 10 from Y for ID 1- I have 11 entries with different ages&amp;nbsp; for ID 1 but then all of the diagnosis that were 1 in 1 ENTRY are repeated as 1 in all other 10 entries even though it should have been 1 only in ONE ENTRY and 0 in all the other 10 (from Y). I thought they would be missing and then I could tell sas to do if dx =. then dx=0. for example.&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;But with all diagnoses = 1 I don't have a way to give a command to transform it to 0. It will transform others (that must remain 1 to 0) - it will overwrite my correct data in Z. Every ID is different:&amp;nbsp; different ages and different amount of entries and diagnoses.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The purpler&amp;nbsp;portion is what you expect, but your expectations are incorrect. If you want this, you need to be able to join by more than ID, ie ID + Event or another variable to uniquely identify each event. If you cannot, a merge links each record by the identified variable and repeats. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So show us a better example of what you want and we can maybe offer some suggestions to get there, but a MERGE/JOIN as shown will not get you there because your logic is more complicated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 02:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522987#M142046</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-21T02:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522988#M142047</link>
      <description>&lt;P&gt;Thank you. I changed to merge by id and age and it worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have another issue:&lt;/P&gt;&lt;P&gt;I need to be able to merge the data when the age is the same.&lt;/P&gt;&lt;P&gt;I am not sure if I can explain but I will try.&lt;/P&gt;&lt;P&gt;When I merge by 2 variables if prevents the overwrite.&lt;/P&gt;&lt;P&gt;But if I have data for the same age for example I have measurements and diagnoses with age 10.&amp;nbsp;&lt;/P&gt;&lt;P&gt;They are in 2 different lines when they should be in one line only.&lt;/P&gt;&lt;P&gt;so ID&amp;nbsp; &amp;nbsp;A B C&amp;nbsp; &amp;nbsp; &amp;nbsp;D E F&amp;nbsp; &amp;nbsp; AGE&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 10 5 5&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp;14&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ID&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 14&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I tell sas to make this entry only one entry ?&lt;/P&gt;&lt;P&gt;This happens in several instances in the data.&lt;/P&gt;&lt;P&gt;Thank you so much&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 03:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522988#M142047</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2018-12-21T03:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522989#M142048</link>
      <description>Post this as a new question and post your sample data as legible as possible. As shown I wouldn't be able to tell you anything. &lt;BR /&gt;&lt;BR /&gt;It's likely a two step process, first consolidate your data and then merge. &lt;BR /&gt;&lt;BR /&gt;Instructions on providing sample data is here, it can be fake data but needs to be legible and representative of your problem. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;</description>
      <pubDate>Fri, 21 Dec 2018 03:19:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522989#M142048</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-21T03:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522990#M142049</link>
      <description>&lt;P&gt;yes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you. I changed the merge by id and age and it worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;it is not overwriting.&lt;/P&gt;&lt;P&gt;Now I have another issue:&lt;/P&gt;&lt;P&gt;I need to be able to merge the data when the age is the same.&lt;/P&gt;&lt;P&gt;I am not sure if I can explain but I will try.&lt;/P&gt;&lt;P&gt;When I merge by 2 variables if prevents the overwrite and this was possible because I was talking about it with you here &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I have data for the same age for example say I have measurements (from the one file) and diagnoses (from the other)&amp;nbsp; with same age 10.&amp;nbsp;&lt;/P&gt;&lt;P&gt;They are in 2 different lines when they should be in one line only.&lt;/P&gt;&lt;P&gt;so&amp;nbsp; &amp;nbsp;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A B C&amp;nbsp; &amp;nbsp; &amp;nbsp;D E F&amp;nbsp; &amp;nbsp; AGE&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10 5 5&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp;14&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; .&amp;nbsp; .&amp;nbsp; &amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 14&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I tell sas to make this entry only one entry for those cases only?&lt;/P&gt;&lt;P&gt;This happens in several instances in the data.&lt;/P&gt;&lt;P&gt;Thank you so much&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 03:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/522990#M142049</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2018-12-21T03:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523022#M142058</link>
      <description>&lt;P&gt;&lt;STRONG&gt;PROVIDE.EXAMPLE.DATA.IN.A.DATA.STEP&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;and your code.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt; has given you a very beautiful example how to do it, and the macro linked to by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; even automates it. Help us to help you.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 08:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523022#M142058</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-21T08:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523055#M142071</link>
      <description>&lt;P&gt;Data want;&lt;/P&gt;&lt;P&gt;Merge Y Z;&lt;/P&gt;&lt;P&gt;by id visit_type;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me a data set with 13.000 observations. Multiple observations for each ID.&lt;/P&gt;&lt;P&gt;Different variables, different ages. Only a couple of ages match from one file to the other.&lt;/P&gt;&lt;P&gt;I need to make sure the ones that do match in age are only in one line instead of 2.&lt;/P&gt;&lt;P&gt;Variables in Y are not the same as in Z aside from id visit_type and age.&amp;nbsp;&lt;/P&gt;&lt;P&gt;but&amp;nbsp; age var has two different names (depending on the file) so it would not overwrite.&lt;/P&gt;&lt;P&gt;one is age_yr the other is visit_age.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do a comparison to see which ones match but then what ?&lt;/P&gt;&lt;P&gt;So this way I can merge them but prevent the overwriting of the other variables... so what is not in Y&amp;nbsp; has to be missing and what is not in Z has to be missing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have a data step for that, it is what I am trying to figure out.&lt;/P&gt;&lt;P&gt;I hope that helps.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Mari&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 13:32:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523055#M142071</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2018-12-21T13:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523076#M142076</link>
      <description>&lt;P&gt;If you merged by ID and AGE and you are getting missmatched records then the value or either ID or AGE do not match.&amp;nbsp; Perhaps your AGE values have been derived and one of them is 14 but the other is really 13.9999999 and it is just printing as 14.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523076#M142076</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-21T15:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523077#M142077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210474"&gt;@Mscarboncopy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Data want;&lt;/P&gt;
&lt;P&gt;Merge Y Z;&lt;/P&gt;
&lt;P&gt;by id visit_type;&lt;/P&gt;
&lt;P&gt;Run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives me a data set with 13.000 observations. Multiple observations for each ID.&lt;/P&gt;
&lt;P&gt;Different variables, different ages. Only a couple of ages match from one file to the other.&lt;/P&gt;
&lt;P&gt;I need to make sure the ones that do match in age are only in one line instead of 2.&lt;/P&gt;
&lt;P&gt;Variables in Y are not the same as in Z aside from id visit_type and age.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but&amp;nbsp; age var has two different names (depending on the file) so it would not overwrite.&lt;/P&gt;
&lt;P&gt;one is age_yr the other is visit_age.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to do a comparison to see which ones match but then what ?&lt;/P&gt;
&lt;P&gt;So this way I can merge them but prevent the overwriting of the other variables... so what is not in Y&amp;nbsp; has to be missing and what is not in Z has to be missing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have a data step for that, it is what I am trying to figure out.&lt;/P&gt;
&lt;P&gt;I hope that helps.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Mari&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I do not see any usable example data, against which we could test code.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523077#M142077</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-21T15:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523078#M142078</link>
      <description>&lt;P&gt;If you want to merge then setup your data so that it can be merged.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge a(rename=(age_a=age)) b(rename=(age_b=age)) ;
  by id age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want more precise help then post a workable example of data that demonstrates your problem.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523078#M142078</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-21T15:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent overwriting on a merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523189#M142137</link>
      <description>&lt;P&gt;Thank you !! I did this and with a few other steps and it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 21:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-overwriting-on-a-merge/m-p/523189#M142137</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2018-12-21T21:27:51Z</dc:date>
    </item>
  </channel>
</rss>

