<?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 copy data to another table via sql update in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/copy-data-to-another-table-via-sql-update/m-p/375283#M89947</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table1&lt;BR /&gt;Date Classifier Count&lt;BR /&gt;2017 A&lt;BR /&gt;2016 A&lt;BR /&gt;2017 B&lt;BR /&gt;2016 B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Note, that the Count column is empty in Table1.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2&lt;BR /&gt;Date Classifier Count&lt;BR /&gt;2017 A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to copy the Count value from Table2 into Table1, where Date and Classifier are matching, so that I get as an updated table:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Updated Table1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Date Classifier Count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2017 A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2016 A&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2017 B&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2016 B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, I tried the following query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;Update Table1&lt;BR /&gt;Set t1.Count = t2.Count&lt;BR /&gt;FROM Table1 t1, Table2 t2&lt;BR /&gt;WHERE t1.Date = t2.Date&lt;BR /&gt;ANDt1.Classifier = t2.Classifier:&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, i only got a syntax error. How can I solve this? Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jul 2017 12:20:07 GMT</pubDate>
    <dc:creator>philip_</dc:creator>
    <dc:date>2017-07-12T12:20:07Z</dc:date>
    <item>
      <title>copy data to another table via sql update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/copy-data-to-another-table-via-sql-update/m-p/375283#M89947</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table1&lt;BR /&gt;Date Classifier Count&lt;BR /&gt;2017 A&lt;BR /&gt;2016 A&lt;BR /&gt;2017 B&lt;BR /&gt;2016 B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Note, that the Count column is empty in Table1.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2&lt;BR /&gt;Date Classifier Count&lt;BR /&gt;2017 A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to copy the Count value from Table2 into Table1, where Date and Classifier are matching, so that I get as an updated table:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Updated Table1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Date Classifier Count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2017 A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2016 A&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2017 B&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2016 B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, I tried the following query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;Update Table1&lt;BR /&gt;Set t1.Count = t2.Count&lt;BR /&gt;FROM Table1 t1, Table2 t2&lt;BR /&gt;WHERE t1.Date = t2.Date&lt;BR /&gt;ANDt1.Classifier = t2.Classifier:&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, i only got a syntax error. How can I solve this? Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 12:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/copy-data-to-another-table-via-sql-update/m-p/375283#M89947</guid>
      <dc:creator>philip_</dc:creator>
      <dc:date>2017-07-12T12:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: copy data to another table via sql update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/copy-data-to-another-table-via-sql-update/m-p/375287#M89949</link>
      <description>&lt;PRE&gt;proc sql;
  update TABLE1 A
  set COUNT=(select COUNT from TABLE2 where DATE=A.DATE and CLASSIFIER=A.CLASSIFIER);
quit;&lt;/PRE&gt;
&lt;P&gt;Try that. &amp;nbsp;If you want tested code then post test data in the form of a datastep.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 12:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/copy-data-to-another-table-via-sql-update/m-p/375287#M89949</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-12T12:31:13Z</dc:date>
    </item>
  </channel>
</rss>

