<?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: Modifying a value in one data set based on another data set in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/383964#M24752</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100243"&gt;@Seabird&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The following should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table_a;
  CLM_NBR=1;
  LOSS_CAUSE = 'MO';
  HAZARD_CODE_INDICATOR='WM';
  output;
  stop;
run;

data table_b;
  CLM_NBR=1;
  HAZARD_CODE_INDICATOR = 'WI';
  VALUES=1;
  output;
  CLM_NBR=1;
  HAZARD_CODE_INDICATOR = 'XX';
  VALUES=1;
  output;
  stop;
run;

proc sql;
  UPDATE TABLE_B AS B
    set HAZARD_CODE_INDICATOR = 'WM'
  where 
    B.HAZARD_CODE_INDICATOR = 'WI' AND
    B.VALUES &amp;lt;&amp;gt; 0 AND
    exists
  	(
  		select *
  		from table_a as a
  	    where
  	      A.CLM_NBR = B.CLM_NBR AND
  	      A.LOSS_CAUSE = 'MO' AND
  	      A.HAZARD_CODE_INDICATOR = 'WM'
  	)	
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 29 Jul 2017 23:01:31 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-07-29T23:01:31Z</dc:date>
    <item>
      <title>Modifying a value in one data set based on another data set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/383774#M24736</link>
      <description>&lt;P&gt;I am trying to modify a value in a field in one data set based on criteria&amp;nbsp;for&amp;nbsp;this and another&amp;nbsp;data set.&amp;nbsp; Here is my current code, which doesn't work.&amp;nbsp; My code should change the hazard code from MO to WM in table B where the claim number is the same between the two tables and there are values in the first table for both loss causes&amp;nbsp;WM and WI.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;UPDATE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;TABLE_B AS B&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;HAZARD_CODE_INDICATOR = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'WM'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;FROM&amp;nbsp;TABLE_A AS A&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;A.CLM_NBR = B.CLM_NBR AND&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;A.LOSS_CAUSE = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'MO'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; AND&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;(B.HAZARD_CODE_INDICATOR = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'WM'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; AND&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;B.VALUES &amp;lt;&amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;) AND&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;(B.HAZARD_CODE_INDICATOR = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'WI'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; AND&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;B.VALUES &amp;lt;&amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Here are the error messages I receive:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;23 proc sql;&lt;/P&gt;&lt;P&gt;24 UPDATE&amp;nbsp;TABLE_B AS B&lt;/P&gt;&lt;P&gt;25 HAZARD_CODE_INDICATOR = 'WM'&lt;/P&gt;&lt;P&gt;_____________________&lt;/P&gt;&lt;P&gt;79&lt;/P&gt;&lt;P&gt;26 FROM FROM&amp;nbsp;TABLE_A AS A&lt;/P&gt;&lt;P&gt;____ __&lt;/P&gt;&lt;P&gt;22 76&lt;/P&gt;&lt;P&gt;202&lt;/P&gt;&lt;P&gt;ERROR 79-322: Expecting a SET.&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, !!, *, **, +, ',', -, /, WHERE, ||.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;26 ! FROM FROM&amp;nbsp;TABLE_A AS A&lt;/P&gt;&lt;P&gt;__&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN,&lt;/P&gt;&lt;P&gt;CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thank you for any help you can provide,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Christine&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 15:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/383774#M24736</guid>
      <dc:creator>Seabird</dc:creator>
      <dc:date>2017-07-28T15:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying a value in one data set based on another data set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/383789#M24737</link>
      <description>&lt;P&gt;I don't think SAS SQL supports updates with a join using SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try creating a new table using SQL rather than updating the table.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 16:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/383789#M24737</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-28T16:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying a value in one data set based on another data set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/383964#M24752</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100243"&gt;@Seabird&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The following should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table_a;
  CLM_NBR=1;
  LOSS_CAUSE = 'MO';
  HAZARD_CODE_INDICATOR='WM';
  output;
  stop;
run;

data table_b;
  CLM_NBR=1;
  HAZARD_CODE_INDICATOR = 'WI';
  VALUES=1;
  output;
  CLM_NBR=1;
  HAZARD_CODE_INDICATOR = 'XX';
  VALUES=1;
  output;
  stop;
run;

proc sql;
  UPDATE TABLE_B AS B
    set HAZARD_CODE_INDICATOR = 'WM'
  where 
    B.HAZARD_CODE_INDICATOR = 'WI' AND
    B.VALUES &amp;lt;&amp;gt; 0 AND
    exists
  	(
  		select *
  		from table_a as a
  	    where
  	      A.CLM_NBR = B.CLM_NBR AND
  	      A.LOSS_CAUSE = 'MO' AND
  	      A.HAZARD_CODE_INDICATOR = 'WM'
  	)	
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jul 2017 23:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/383964#M24752</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-07-29T23:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying a value in one data set based on another data set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/384399#M24767</link>
      <description>&lt;P&gt;Thank you very much, Patrick!&amp;nbsp; You saved my bacon!&amp;nbsp; I've been struggling with this for a while and was nearing a deadline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seabird&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Modifying-a-value-in-one-data-set-based-on-another-data-set/m-p/384399#M24767</guid>
      <dc:creator>Seabird</dc:creator>
      <dc:date>2017-07-31T19:13:53Z</dc:date>
    </item>
  </channel>
</rss>

