<?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 merge in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186838#M14296</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can I &lt;SPAN class="hps"&gt;do&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a merge&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;between&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;2 boards&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;and take&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the values&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;​​of Table 2&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in case&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in Table&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;1 have&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in those places&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a specific value&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hps"&gt;thank you very much&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hps"&gt;Maria&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Jan 2014 20:20:58 GMT</pubDate>
    <dc:creator>Lopes</dc:creator>
    <dc:date>2014-01-02T20:20:58Z</dc:date>
    <item>
      <title>merge</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186838#M14296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can I &lt;SPAN class="hps"&gt;do&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a merge&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;between&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;2 boards&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;and take&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the values&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;​​of Table 2&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in case&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in Table&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;1 have&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in those places&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a specific value&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hps"&gt;thank you very much&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hps"&gt;Maria&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2014 20:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186838#M14296</guid>
      <dc:creator>Lopes</dc:creator>
      <dc:date>2014-01-02T20:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186839#M14297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without having a sample of your data and expected output, I can only provide a general reply. There are several ways you could do this. Here are two options:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. use a data step to merge the two datasets together, replacing the values in Table 1 with the values from Table 2 if the specified condition is met in Table 1. For this step to work, the data should be pre-sorted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA together ;&lt;/P&gt;&lt;P&gt;merge table1 (in=a rename=(var1=table1var)) table2 (in=b rename=(var2=table2var));&lt;/P&gt;&lt;P&gt;by idno ; /* your by variables go here -- make sure tables are presorted */&lt;/P&gt;&lt;P&gt;if a and b then do ; /* change as needed to get only left side (if a) or right side (if b) or either side (if a or b), etc. */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if table1var = 999 then var1 = table2var;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else var1 = table1var ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. use PROC SQL - no need to presort the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table together as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select t1.idno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ( case when t1.idno = 999 then t2.var1 else t1.var1 end ) as var1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from table1 as t1, table2 as t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where t1.idno = t2.idno /* assumes you want an equijoin */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by idno&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These are only two approaches -- there are other methods that you could use.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2014 20:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186839#M14297</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2014-01-02T20:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186840#M14298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have in the table1 25 variables in 6 of them I have the value 999999, in those cases I need to replace in the new table those values with the ones in table 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was not able to attach the tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have I explained better what I need?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example "IDNO" is the name of the table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2014 20:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186840#M14298</guid>
      <dc:creator>Lopes</dc:creator>
      <dc:date>2014-01-02T20:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186841#M14299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my example, I used IDNO as an example of the variable(s) that you would use to do the join. IDNO, in my example, is a fictional variable. Instead of IDNO, use the actual variable(s) that you are using to join the tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I said, my response is general in nature since we don't have any sample data or expected output to work with. You don't need to attach the entire table(s), by the way. You can attach subsets of the data, or even samples with fictional data if you are concerned about privacy/confidentiality issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding 6 variables having values of 999999, you can reuse the code samples I provided to recode as many variables as needed, eg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA together ;&lt;/P&gt;&lt;P&gt;merge table1 (in=a rename=(var1=table1var1 var2=table1var2 var3=table1var3 . . . etc . . .&amp;nbsp; )) table2 (in=b rename=(var1=table2var1 var2=table2var2 var3=table2var3 . . . . etc . . . ));&lt;/P&gt;&lt;P&gt;by idno ; /* fictional join variable - to be replaced with your actual by variable(s) -- make sure tables are presorted */&lt;/P&gt;&lt;P&gt;if a and b then do ; /* change as needed to get only left side (if a) or right side (if b) or either side (if a or b), etc. */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if table1var1 = 999999 then var1 = table2var1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else var1 = table1var1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if table1var2 = 999999 then var2 = table2var2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else var2 = table1var2 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if table1var3 = 999999 then var3 = table2var3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else var3 = table1var3 ;&lt;/P&gt;&lt;P&gt;. . . .&lt;/P&gt;&lt;P&gt;more lines &lt;/P&gt;&lt;P&gt;. . . . &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR in PROC SQL . . . .&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table together as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select t1.idno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ( case when t1.var1 = 999999 then t2.var1 else t1.var1 end ) as var1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ( case when t1.var2 = 999999 then t2.var2 else t1.var2 end ) as var2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ( case when t1.var3 = 999999 then t2.var3 else t1.var3 end ) as var3&lt;/P&gt;&lt;P&gt;. . . . more case statements . . . &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from table1 as t1, table2 as t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where t1.idno = t2.idno /* fictional join variable. Assumes you want an equijoin */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by idno&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2014 22:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186841#M14299</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2014-01-02T22:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186842#M14300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried. The problema when using PROC SQL is that I in table 2 I only have the values with 999999 in table 1. And when doing this I need to have al the variables in table 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another question, can I do this with more tan 2 tables? For instance take 3 variables from table 2, 5 from table 3, ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jan 2014 12:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186842#M14300</guid>
      <dc:creator>Lopes</dc:creator>
      <dc:date>2014-01-03T12:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: merge</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186843#M14301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use this general approach (either Data Step method or PROC SQL method) with more than 2 tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you mean by, ". . . I need to have all the variables in table 2"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To help you any further, I think I need to see a sample of your input data and a sample of your desired output.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jan 2014 19:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/merge/m-p/186843#M14301</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2014-01-03T19:08:29Z</dc:date>
    </item>
  </channel>
</rss>

