<?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 Question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111116#M30798</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you are trying for this combination:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data out1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; update old new;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by cust_id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read up a little bit on UPDATE ... it's probably the right tool for the job.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Feb 2013 20:23:49 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2013-02-15T20:23:49Z</dc:date>
    <item>
      <title>Merge Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111115#M30797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am merging two datasets: old and new.&amp;nbsp;&amp;nbsp; Dataset old has historical data from prior dates and contains 900 columns.&amp;nbsp; Dataset new has 800 columns and contains new data for today, and hese 800 columns also exist in OLD.&amp;nbsp; I would like to update the common 800 columns in OLD with value from NEW and keep the other 100 columns in OLD as is where cust_id is in both OLD and NEW.&amp;nbsp;&amp;nbsp;&amp;nbsp; The code below attemps to do that.&amp;nbsp; But I couldn't possibly list all 800 columns in the data step.&amp;nbsp; See the sample data below.&amp;nbsp; Dataset OUT1 has the 1st 100 columns from OLD and columns 101 to column 900 are populated with value from NEW.&amp;nbsp; I hope this makes sense.&amp;nbsp; Does anyone have any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data out1;&lt;/P&gt;&lt;P&gt;merge old (in=a) new (in=b);&lt;/P&gt;&lt;P&gt;by cust_id;&lt;/P&gt;&lt;P&gt;if a or b;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if a = 0 and b = 1 then col1 = new_col1;&lt;/P&gt;&lt;P&gt;if a = 0 and b = 1 then col2 = new_col2;&lt;/P&gt;&lt;P&gt;..&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;&lt;/P&gt;&lt;P&gt;Dataset OLD:&lt;/P&gt;&lt;P&gt;cust_id col1 col2 col3 ...col100, col101, col102,..&amp;nbsp; col898, col899, col 900&lt;/P&gt;&lt;P&gt;111111&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;aa&amp;nbsp;&amp;nbsp; bb&amp;nbsp;&amp;nbsp; cc ....&amp;nbsp;&amp;nbsp; dd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;gg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kk&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ff&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ll&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kk&lt;/P&gt;&lt;P&gt;222222&amp;nbsp;&amp;nbsp; bb&amp;nbsp;&amp;nbsp; cc&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ....&amp;nbsp;&amp;nbsp; bc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ee&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qq&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dataset NEW:&lt;/P&gt;&lt;P&gt;cust_id col1 col2... col798, col799, col800&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;111111 &lt;/STRONG&gt;&lt;STRONG&gt;uu&amp;nbsp;&amp;nbsp; ww....&amp;nbsp;&amp;nbsp; xx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yy&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zz&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dataset OUT1:&lt;/P&gt;&lt;P&gt;cust_id col1 col2 col3 ... col100, col101, col102,..&amp;nbsp; col898, col899, col900&lt;/P&gt;&lt;P&gt;111111&amp;nbsp; &lt;STRONG&gt;aa&amp;nbsp;&amp;nbsp;&amp;nbsp; bb&amp;nbsp;&amp;nbsp; cc....&amp;nbsp;&amp;nbsp;&amp;nbsp; dd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;uu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ww....&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yy&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zz&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 19:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111115#M30797</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2013-02-15T19:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111116#M30798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you are trying for this combination:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data out1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; update old new;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by cust_id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read up a little bit on UPDATE ... it's probably the right tool for the job.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 20:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111116#M30798</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-02-15T20:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111117#M30799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would assume that your cust_id is unique, and you want variable in NEW col1-col800 to replace those of col101-col900 in old, if that is the case, all you need to do is to rename the incoming variables from NEW during the merge: (the caveat of this approach is the total length of macro variable is only 32k)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select cats(name,'=',cats(compress(name,,'ka'),input(compress(name,,'kd'),best.)+100)) into :name separated by ' ' &lt;/P&gt;&lt;P&gt;&amp;nbsp; from dictionary.columns where libname='YOURLIB'/*NEED TO BE CAPPED*/ AND MEMNAME='NEW' /*CAPPED*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; and name contains 'col';&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data out1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge old new(rename=(&amp;amp;name));&lt;/P&gt;&lt;P&gt;&amp;nbsp; by cust_id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 20:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111117#M30799</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-02-15T20:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111118#M30800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Starting with SAS9 the size of macro variables has been increased to 64K. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Feb 2013 06:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111118#M30800</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2013-02-17T06:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111119#M30801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the update, Art!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 14:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Question/m-p/111119#M30801</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-02-19T14:45:14Z</dc:date>
    </item>
  </channel>
</rss>

