<?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 using inner join in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Update-using-inner-join/m-p/576233#M75481</link>
    <description>&lt;P&gt;The SET keyword has a variable name and a value.&lt;/P&gt;
&lt;P&gt;You can generate the value using a correlated subquery, just make sure it returns only one observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you trying to tell UPDATE which observations to change?&amp;nbsp; For that you use a WHERE condition.&amp;nbsp; Again if the test to identify which observations to update involves another dataset then use a subquery, perhaps using EXISTS ().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;update AllDataSimple
  set AllDataSimple.gasprice = 
 ( select forward_gasprices.price 
   from AllDataSimple 
   inner join work.forward_gasprices
     on forward_gasprices.DeliveryDate = AllDataSimple.DeliveryDate
     and forward_gasprices.DeliveryDate &amp;gt; today()-1
 )

where exists 
 ( select forward_gasprices.price 
   from AllDataSimple 
   inner join work.forward_gasprices
     on forward_gasprices.DeliveryDate = AllDataSimple.DeliveryDate
     and forward_gasprices.DeliveryDate &amp;gt; today()-1
 )
	;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Jul 2019 16:15:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-07-24T16:15:51Z</dc:date>
    <item>
      <title>Update using inner join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-using-inner-join/m-p/576225#M75480</link>
      <description>&lt;P&gt;Hello New to SAS and new to the forum&amp;nbsp; I am just wondering if There is a way to update a table using a inner join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Proc SQL;
	update AllDataSimple
	set AllDataSimple.gasprice = forward_gasprices.price
	from AllDataSimple
	inner join work.forward_gasprices
	on forward_gasprices.DeliveryDate = AllDataSimple.DeliveryDate
	where forward_gasprices.DeliveryDate &amp;gt; today()-1
	;
QUIT&lt;/PRE&gt;&lt;P&gt;SAS only highlights UPDATE&amp;nbsp; and SET and I get an error:&lt;/P&gt;&lt;P&gt;Expecting an =.&amp;nbsp; (affected code&amp;nbsp;set AllDataSimple.gasprice = forward_gasprices.price)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I search for a solution the error only came up when there was a syntax error and I am sorry if that is the case but it really seems to me like SAS just doesn't like the from or inner join and the set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 16:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-using-inner-join/m-p/576225#M75480</guid>
      <dc:creator>jbull</dc:creator>
      <dc:date>2019-07-24T16:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Update using inner join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-using-inner-join/m-p/576233#M75481</link>
      <description>&lt;P&gt;The SET keyword has a variable name and a value.&lt;/P&gt;
&lt;P&gt;You can generate the value using a correlated subquery, just make sure it returns only one observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you trying to tell UPDATE which observations to change?&amp;nbsp; For that you use a WHERE condition.&amp;nbsp; Again if the test to identify which observations to update involves another dataset then use a subquery, perhaps using EXISTS ().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;update AllDataSimple
  set AllDataSimple.gasprice = 
 ( select forward_gasprices.price 
   from AllDataSimple 
   inner join work.forward_gasprices
     on forward_gasprices.DeliveryDate = AllDataSimple.DeliveryDate
     and forward_gasprices.DeliveryDate &amp;gt; today()-1
 )

where exists 
 ( select forward_gasprices.price 
   from AllDataSimple 
   inner join work.forward_gasprices
     on forward_gasprices.DeliveryDate = AllDataSimple.DeliveryDate
     and forward_gasprices.DeliveryDate &amp;gt; today()-1
 )
	;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jul 2019 16:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-using-inner-join/m-p/576233#M75481</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-24T16:15:51Z</dc:date>
    </item>
  </channel>
</rss>

