<?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: update table from another table in sas in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856724#M42157</link>
    <description>&lt;P&gt;I already gave you the answer.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2023 19:28:47 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-02-01T19:28:47Z</dc:date>
    <item>
      <title>update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856693#M42146</link>
      <description>&lt;P&gt;update sample1 from another sample2 in sas&lt;/P&gt;
&lt;P&gt;match id and code then exp update&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example.363823 and 52 matched then put 5.&lt;/P&gt;
&lt;P&gt;i want this type of query ..Pls help&lt;/P&gt;
&lt;P&gt;sample data&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample1;
  input ID 1-6 code 7-9 exp 10-11;
  datalines;
363823	52	0
363823	53	0
293556	50	0
293556	51	0
293556	52	0
293556	53	0
;

data sample2;
  input ID 1-6 code 7-9 exp 10-11;
  datalines;
363823	52	5
363823	53	8
293556	50	9
;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I want this type of output&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daily1_0-1675272549675.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80007i1409231C10B44900/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daily1_0-1675272549675.png" alt="Daily1_0-1675272549675.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 17:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856693#M42146</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2023-02-01T17:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856702#M42149</link>
      <description>&lt;P&gt;Looks like you are doing a homework.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;step 1) use Proc Sort and sort both datasets by ID and Code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;step 2) use Merge statement to combine both data sets by ID and Code, remember to use them in the Merge statement in order "sample1 sample2" so the values of exp variable form the second one will overwrite values of exp from the first one (only in case when there is a match by ID and Code of course)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try to do it yourself, in case of problems - ask&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 18:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856702#M42149</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-02-01T18:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856707#M42150</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update sample1 set exp= select n.exp from sample2 as n 
where n.id=sample1.id and n.code =sample1.code;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please Help&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 18:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856707#M42150</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2023-02-01T18:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856712#M42151</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daily1_0-1675277118002.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80008i2CB1B6EA4922F02A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daily1_0-1675277118002.png" alt="Daily1_0-1675277118002.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Sql Code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daily1_1-1675277271407.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80009iB333CD2D0BD53C10/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daily1_1-1675277271407.png" alt="Daily1_1-1675277271407.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daily1_2-1675277348568.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80010i19356AC20F5EDFBE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daily1_2-1675277348568.png" alt="Daily1_2-1675277348568.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;this code not working on sas eg ...please help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 18:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856712#M42151</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2023-02-01T18:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856716#M42152</link>
      <description>&lt;P&gt;Maxim 2: Read the Log.&lt;/P&gt;
&lt;P&gt;If that does not give you a clue, post it here.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 19:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856716#M42152</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-01T19:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856717#M42153</link>
      <description>proc sql;&lt;BR /&gt;update sample1 set exp= (select n.exp from sample2 as n )&lt;BR /&gt;where n.id=sample1.id and n.code =sample1.code;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;log &lt;BR /&gt;proc sql;&lt;BR /&gt;29         update sample1 set exp= (select n.exp from sample2 as n )&lt;BR /&gt;30         where n.id=sample1.id and n.code =sample1.code;&lt;BR /&gt;ERROR: Unresolved reference to table/correlation name n.&lt;BR /&gt;ERROR: Unresolved reference to table/correlation name n.&lt;BR /&gt;ERROR: Expression using equals (=) has components that are of different data types.&lt;BR /&gt;ERROR: Expression using equals (=) has components that are of different data types.&lt;BR /&gt;31         quit;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Feb 2023 19:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856717#M42153</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2023-02-01T19:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856719#M42154</link>
      <description>&lt;P&gt;The WHERE clause must be part of the sub-select.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 19:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856719#M42154</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-01T19:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856721#M42155</link>
      <description>&lt;P&gt;Why not just skip the SQL and use normal SAS code?&lt;/P&gt;
&lt;P&gt;The UPDATE statement is for applying transactions to existing datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample1;
  input ID code exp ;
datalines;
293556	50	0
293556	51	0
293556	52	0
293556	53	0
363823	52	0
363823	53	0
;

data sample2;
  input ID code exp ;
datalines;
293556	50	9
363823	52	5
363823	53	8
;

/*
proc sort data=sample1; by id code; run;
proc sort data=sample2; by id code; run;
*/

data want;
  update sample1 sample2;
  by id code ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2023 19:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856721#M42155</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-01T19:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856723#M42156</link>
      <description>proc sql;&lt;BR /&gt;update sample1 set exp= (select n.exp from sample2  n )&lt;BR /&gt;where n.id=sample1.id and n.code =sample1.code;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;Please correct query</description>
      <pubDate>Wed, 01 Feb 2023 19:24:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856723#M42156</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2023-02-01T19:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856724#M42157</link>
      <description>&lt;P&gt;I already gave you the answer.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 19:28:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856724#M42157</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-01T19:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856726#M42159</link>
      <description>&lt;P&gt;That photograph does not appear to be proper SQL syntax for how the UPDATE statement works.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Update_(SQL)" target="_blank"&gt;https://en.wikipedia.org/wiki/Update_(SQL)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;UPDATE&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;statement has the following form:&lt;SUP id="cite_ref-1" class="reference"&gt;&lt;/SUP&gt;&lt;/P&gt;
&lt;DL&gt;
&lt;DD&gt;&lt;STRONG&gt;&lt;CODE&gt;UPDATE&lt;/CODE&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;table_name&lt;/I&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;CODE&gt;SET&lt;/CODE&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;column_name&lt;/I&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;value&lt;/I&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;[,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;column_name&lt;/I&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;value ...&lt;/I&gt;] [&lt;STRONG&gt;&lt;CODE&gt;WHERE&lt;/CODE&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;condition&lt;/I&gt;]&lt;/DD&gt;
&lt;/DL&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perhaps it is some extension provided by some other database language you have used in the past?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 19:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856726#M42159</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-01T19:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: update table from another table in sas</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856727#M42160</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236411"&gt;@Daily1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update sample1 set exp= select n.exp from sample2 as n 
where n.id=sample1.id and n.code =sample1.code;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please Help&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you mean&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;update sample1 
set exp= 
 (select n.exp from sample2 n 
  where n.id=sample1.id and n.code =sample1.code
 )
where exists (select n.exp from sample2 n 
  where n.id=sample1.id and n.code =sample1.code
 )
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2023 19:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/update-table-from-another-table-in-sas/m-p/856727#M42160</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-01T19:42:43Z</dc:date>
    </item>
  </channel>
</rss>

