<?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: Data merging in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592716#M169966</link>
    <description>&lt;P&gt;Are you just saying you want to read two observations from the TWO for every observation read from ONE?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set one;
  do rep=1 to 2;
    set two;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Sep 2019 15:20:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-09-30T15:20:51Z</dc:date>
    <item>
      <title>Data merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592642#M169947</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using SAS 9.4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to merge 2 data sets by a specific ID that is not the same? Meaning I have 2 data sets where I want to keep all information from both data sets and have the data in a wide format. The only problem is the data is a 1:2 merge with ID that do not match. Is there a good method to perform this? Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;ID2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; 8&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; 90&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; 15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I need to have 2 rows with ID 1 and merge in ID 10 and 20 on the same row as ID 1 to create the data set? Any thoughts would be helpful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 12:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592642#M169947</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2019-09-30T12:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Data merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592643#M169948</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp;can you post what the two data sets that should result in your posted data set looks like?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 12:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592643#M169948</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-09-30T12:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Data merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592647#M169949</link>
      <description>&lt;P&gt;I cannot. The data sets are primarily PHI with the exception of the ID and a key of which IDs should be mapped together. I know it is not much to go on but my question was as much theoretical of if it could be done. Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 12:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592647#M169949</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2019-09-30T12:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Data merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592668#M169954</link>
      <description>&lt;P&gt;I would create a third table that would hold the associations between ID and ID2 using PROC SQL.&amp;nbsp; This third table would be primary table that table 1 and table 2 would join on.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 13:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592668#M169954</guid>
      <dc:creator>utrocketeng</dc:creator>
      <dc:date>2019-09-30T13:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Data merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592699#M169962</link>
      <description>&lt;P&gt;And how do we know that 90 and 15&amp;nbsp;is supposed to match 3? or 3 and 8 match 2?&lt;/P&gt;
&lt;P&gt;Computers run on rules. Without a rule you are going to have a very hard time telling the computer what to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you duplicate records for the first set would you have the same of records in both data sets so a one-to-one would work? Is the second data set then in the correct order to match with data one? If so this may help:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data onetemp;
   set dataone;
   output;
   output;
run;

data want;
   merge onetemp datatwo;
run;&lt;/PRE&gt;
&lt;P&gt;otherwise you are going to have to come up with some rule for connecting to the two sets of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And perhaps some attention should be paid to having proper identification variables at compilation in the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 14:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592699#M169962</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-30T14:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Data merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592716#M169966</link>
      <description>&lt;P&gt;Are you just saying you want to read two observations from the TWO for every observation read from ONE?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set one;
  do rep=1 to 2;
    set two;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Sep 2019 15:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592716#M169966</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-30T15:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Data merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592719#M169969</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;DIV class="page"&gt;&lt;DIV class="section"&gt;&lt;DIV class="layoutArea"&gt;&lt;DIV class="column"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would suggest the "One-to-one reading" method to combine your datasets.&lt;/P&gt;&lt;P&gt;This method will create observations that contain all of the variables from each contributing data set.&lt;/P&gt;&lt;P&gt;The combines observations will be based on their relative position in each source data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set source1;&lt;/P&gt;&lt;P&gt;set source2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;warning : you need to be sure that you have the same amount of observation in source data sets, and that the position of an observation in one dataset is the same than the one in the&amp;nbsp;second source data set that you want to combine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this help!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 30 Sep 2019 15:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-merging/m-p/592719#M169969</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-09-30T15:30:40Z</dc:date>
    </item>
  </channel>
</rss>

