<?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 two variables from two tables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123382#M33900</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza thank you very much for this quick reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set and keep procedure work well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only thing is that I am not able to make the part in bold work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set mylib.test1 (keep=name date) mylib.test2 (keep=name date)&lt;STRONG&gt; indsname=source;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: END, KEY, KEYS, NOBS, POINT. &lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;source_table=source;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error points on the equal sign between indsname=source&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Feb 2013 22:13:48 GMT</pubDate>
    <dc:creator>nicnad</dc:creator>
    <dc:date>2013-02-27T22:13:48Z</dc:date>
    <item>
      <title>Merge two variables from two tables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123380#M33898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say I have the two following table :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table : mylib.Test1&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; WIDTH: 100%; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Var1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Var2&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;John&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-01&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;aaa&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;bbb&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Bob&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-02&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;eee&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ccc&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Peter&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-03&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ffff&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ddd&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table : Mylib.test2&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; WIDTH: 100%; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Var9&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Bob&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-04&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ttt&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Fred&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-05&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;yyy&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Will&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-05&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;vvv&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to merge the two tables, so that I have all the names, dates, and the source table dates (and if name should be repeated, have the multiple entries) like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; WIDTH: 100%; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Source_Table&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;John&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-01&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;test1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Bob&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-02&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;test1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Peter&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-03&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;test1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Bob&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-04&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;test2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Fred&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-05&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;test2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Will&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-01-05&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;test2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thank you very much for your help and time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 21:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123380#M33898</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-02-27T21:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two variables from two tables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123381#M33899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you don't need var1, var2 and var9 then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set mylib.test1 (keep=name date) mylib.test2 (keep=name date) indsname=source;&lt;/P&gt;&lt;P&gt;source_table=source;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 21:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123381#M33899</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-27T21:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two variables from two tables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123382#M33900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza thank you very much for this quick reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set and keep procedure work well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only thing is that I am not able to make the part in bold work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set mylib.test1 (keep=name date) mylib.test2 (keep=name date)&lt;STRONG&gt; indsname=source;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: END, KEY, KEYS, NOBS, POINT. &lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;source_table=source;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error points on the equal sign between indsname=source&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 22:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123382#M33900</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-02-27T22:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two variables from two tables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123383#M33901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That means you have SAS 9.1?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set mylib.test1 (keep=name date in=test1) mylib.test2 (keep=name date in=test2);&lt;/P&gt;&lt;P&gt;if test1 then source_table='test1';&lt;/P&gt;&lt;P&gt;else if test2 then source_table='test2';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 22:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123383#M33901</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-27T22:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two variables from two tables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123384#M33902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is exactly what I needed it works great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing is that I am using the set procedure on 10 different table. Is there an another then writing 10 if statements?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I just state something like source_table = in?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I see that the length of my variable source_table is set to 5 (with the first value being test1 I guess) so when afterwards I use a longer string it is truncated to 5 chars only. How do I solve this%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your help and time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 23:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123384#M33902</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-02-27T23:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two variables from two tables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123385#M33903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Getting away from the IF-THEN/ELSE is why the INDSNAME= option was added to the SET statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can declare the variable's length using the LENGTH statement.&amp;nbsp; Right after the SET statement add something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length source_table $7;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 06:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123385#M33903</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2013-02-28T06:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two variables from two tables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123386#M33904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your replies!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 15:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-variables-from-two-tables/m-p/123386#M33904</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-02-28T15:30:49Z</dc:date>
    </item>
  </channel>
</rss>

