<?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: Updating dataset or Merging by variables using SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670348#M201210</link>
    <description>&lt;P&gt;It is "on" not "bon". The error was made while posting it.&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jul 2020 17:20:15 GMT</pubDate>
    <dc:creator>sas_apprenant</dc:creator>
    <dc:date>2020-07-18T17:20:15Z</dc:date>
    <item>
      <title>Updating dataset or Merging by variables using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670347#M201209</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data1.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47281i7B0F223A482338BA/image-size/large?v=v2&amp;amp;px=999" role="button" title="data1.PNG" alt="data1.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data2.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47280iDE613E79BFCB2CC4/image-size/large?v=v2&amp;amp;px=999" role="button" title="data2.PNG" alt="data2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried to merge both datasets based on the variables ClassVal0 and param. For some reason though the coding I used is not working. First I tried to update based using this code below before merging but it said&amp;nbsp;&lt;FONT color="#FF6600"&gt;&lt;SPAN&gt;SQL Update: ERROR: Subquery evaluated to more than one row.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	update bout.allm as a
	set ClassVal0 = (select (ClassVal0) 
	from nhns.chdsimplogtab as b 
	where a.Param = b.Param
	group by b.Param);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;Then I just tried to combine them together based on this code below and it just didn't&amp;nbsp;work out with values mismatched.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;&lt;BR /&gt;create table mamlogistictable as&lt;BR /&gt;select a.*, b.M_OR_CI, b.M_p_value, b.M_g_p_value&lt;BR /&gt;from btab.lnelmam_simplogtab a&lt;BR /&gt;left join bout.allm b&lt;BR /&gt;on a.ClassVal0 = b.ClassVal0 &lt;BR /&gt;and a.Param = b.Param&lt;BR /&gt;order by Param;&lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;What am I doing wrong? I'd appreciate the explanation. &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 19:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670347#M201209</guid>
      <dc:creator>sas_apprenant</dc:creator>
      <dc:date>2020-07-18T19:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Updating dataset or Merging by variables using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670348#M201210</link>
      <description>&lt;P&gt;It is "on" not "bon". The error was made while posting it.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 17:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670348#M201210</guid>
      <dc:creator>sas_apprenant</dc:creator>
      <dc:date>2020-07-18T17:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Updating dataset or Merging by variables using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670350#M201212</link>
      <description>&lt;P&gt;Please post data as text, not photographs.&amp;nbsp; Limit to enough variables and observations to demonstrate the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As the error says to use a subquery to update a value with the UPDATE statement in SQL the subquery must return only one value.&amp;nbsp; Which of the many values to you want to use? Is there some way to pick the right one?&amp;nbsp; Perhaps you want the min or max value?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 17:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670350#M201212</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-18T17:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Updating dataset or Merging by variables using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670364#M201218</link>
      <description>&lt;P&gt;Based on the *pictures* of the data, the join should work. Try replacing the &lt;STRONG&gt;left join&lt;/STRONG&gt; with an &lt;STRONG&gt;inner join&lt;/STRONG&gt;. Please give a more detailed description of the missmatch that you obtain.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 18:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670364#M201218</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-07-18T18:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Updating dataset or Merging by variables using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670365#M201219</link>
      <description>&lt;P&gt;I tried the inner join and the output does not work with what I want. Essentially, I want to add the output of my adjusted regression analysis to simple regression with the adjusted odd ratios, CIs, and global p-value. Using inner join, I got the attached result (file added). Also, I added the files from the original.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 19:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670365#M201219</guid>
      <dc:creator>sas_apprenant</dc:creator>
      <dc:date>2020-07-18T19:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Updating dataset or Merging by variables using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670387#M201233</link>
      <description>&lt;P&gt;I think you were arleady getting the right resuIts, but the ordering was confusing. I get decent results with :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table mamlogistictable as
select  
    a.*, 
    b.M_OR_CI, 
    b.M_p_value, 
    b.M_g_p_value
from 
    sasforum.lnelmam_simplogtab a left join 
    sasforum.allm b on a.ClassVal0 = b.ClassVal0 and a.Param = b.Param
order by f_ord;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Replace &lt;EM&gt;sasforum&lt;/EM&gt; with your own library names.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 20:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670387#M201233</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-07-18T20:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Updating dataset or Merging by variables using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670733#M201388</link>
      <description>&lt;P&gt;I realized I was on the right track and figured it out. Thank you for the guidance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate it!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 17:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-dataset-or-Merging-by-variables-using-SQL/m-p/670733#M201388</guid>
      <dc:creator>sas_apprenant</dc:creator>
      <dc:date>2020-07-20T17:48:49Z</dc:date>
    </item>
  </channel>
</rss>

