<?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 PROC SQL Update field from one table with information from another in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Update-field-from-one-table-with-information-from/m-p/760208#M80888</link>
    <description>&lt;P&gt;Hi there, I'm trying to update some specific fields in a table(solicitudes) from oracle with information from another table(originacion_decision).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the oracle table &lt;STRONG&gt;solicitudes&lt;/STRONG&gt; I have two fields,&amp;nbsp;&lt;STRONG&gt;score&lt;/STRONG&gt; and &lt;STRONG&gt;decision_id,&amp;nbsp;&lt;/STRONG&gt;those fields are null and I have to update them with the fields&lt;STRONG&gt; score&lt;/STRONG&gt; and &lt;STRONG&gt;decision&lt;/STRONG&gt; from the table &lt;STRONG&gt;originacion_decision&lt;/STRONG&gt; only with the matching ones&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using this code with proc sql procedure, but it still doesn't work, really don't know why I'm doing wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The unique key is a combination of the fields&amp;nbsp;&lt;CODE class=" language-sas"&gt;tipo_identificacion,&amp;nbsp;nro_identificacion,&amp;nbsp;nro_solicitud,&amp;nbsp;codigo_subproducto&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sasvi oracle user=&amp;amp;user password= &amp;amp;pswd
	path=&amp;amp;path

cas mysess sessopts=(caslib=Public);
libname Public cas caslib=Public datalimit=all;
caslib _all_ assign;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;proc sort data=Public.originacion_decision out= Public.originacion_decision nodupkey;&lt;BR /&gt;	by nro_identificacion tipo_identificacion nro_solicitud;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=sasvi.solicitudes out=Public.originacion_decision nodupkey;&lt;BR /&gt;	by nro_identificacion tipo_identificacion nro_solicitud;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;	update sasvi.solicitudes as ora set score=(select id.score from &lt;BR /&gt;		Public.originacion_decision as id where ora.score=. and &lt;BR /&gt;		ora.tipo_identificacion=id.tipo_identificacion and &lt;BR /&gt;		ora.nro_identificacion=id.nro_identificacion and &lt;BR /&gt;		ora.codigo_subproducto=id.codigo_subproducto and &lt;BR /&gt;		ora.nro_solicitud=id.nro_solicitud),&lt;BR /&gt;		decision_id=(select id.decision from &lt;BR /&gt;		Public.originacion_decision as id where ora.decision_id="" and &lt;BR /&gt;		ora.tipo_identificacion=id.tipo_identificacion and &lt;BR /&gt;		ora.nro_identificacion=id.nro_identificacion and &lt;BR /&gt;		ora.codigo_subproducto=id.codigo_subproducto and &lt;BR /&gt;		ora.nro_solicitud=id.nro_solicitud) &lt;BR /&gt;		where exists (select * from &lt;BR /&gt;		Public.originacion_decision as id where &lt;BR /&gt;		ora.tipo_identificacion=id.tipo_identificacion and &lt;BR /&gt;		ora.nro_identificacion=id.nro_identificacion and &lt;BR /&gt;		ora.codigo_subproducto=id.codigo_subproducto and &lt;BR /&gt;		ora.nro_solicitud=id.nro_solicitud);&lt;BR /&gt;quit;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'll be grateful if somebody help me!&lt;/P&gt;</description>
    <pubDate>Sun, 08 Aug 2021 04:58:35 GMT</pubDate>
    <dc:creator>valengvz</dc:creator>
    <dc:date>2021-08-08T04:58:35Z</dc:date>
    <item>
      <title>PROC SQL Update field from one table with information from another</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Update-field-from-one-table-with-information-from/m-p/760208#M80888</link>
      <description>&lt;P&gt;Hi there, I'm trying to update some specific fields in a table(solicitudes) from oracle with information from another table(originacion_decision).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the oracle table &lt;STRONG&gt;solicitudes&lt;/STRONG&gt; I have two fields,&amp;nbsp;&lt;STRONG&gt;score&lt;/STRONG&gt; and &lt;STRONG&gt;decision_id,&amp;nbsp;&lt;/STRONG&gt;those fields are null and I have to update them with the fields&lt;STRONG&gt; score&lt;/STRONG&gt; and &lt;STRONG&gt;decision&lt;/STRONG&gt; from the table &lt;STRONG&gt;originacion_decision&lt;/STRONG&gt; only with the matching ones&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using this code with proc sql procedure, but it still doesn't work, really don't know why I'm doing wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The unique key is a combination of the fields&amp;nbsp;&lt;CODE class=" language-sas"&gt;tipo_identificacion,&amp;nbsp;nro_identificacion,&amp;nbsp;nro_solicitud,&amp;nbsp;codigo_subproducto&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sasvi oracle user=&amp;amp;user password= &amp;amp;pswd
	path=&amp;amp;path

cas mysess sessopts=(caslib=Public);
libname Public cas caslib=Public datalimit=all;
caslib _all_ assign;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;proc sort data=Public.originacion_decision out= Public.originacion_decision nodupkey;&lt;BR /&gt;	by nro_identificacion tipo_identificacion nro_solicitud;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=sasvi.solicitudes out=Public.originacion_decision nodupkey;&lt;BR /&gt;	by nro_identificacion tipo_identificacion nro_solicitud;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;	update sasvi.solicitudes as ora set score=(select id.score from &lt;BR /&gt;		Public.originacion_decision as id where ora.score=. and &lt;BR /&gt;		ora.tipo_identificacion=id.tipo_identificacion and &lt;BR /&gt;		ora.nro_identificacion=id.nro_identificacion and &lt;BR /&gt;		ora.codigo_subproducto=id.codigo_subproducto and &lt;BR /&gt;		ora.nro_solicitud=id.nro_solicitud),&lt;BR /&gt;		decision_id=(select id.decision from &lt;BR /&gt;		Public.originacion_decision as id where ora.decision_id="" and &lt;BR /&gt;		ora.tipo_identificacion=id.tipo_identificacion and &lt;BR /&gt;		ora.nro_identificacion=id.nro_identificacion and &lt;BR /&gt;		ora.codigo_subproducto=id.codigo_subproducto and &lt;BR /&gt;		ora.nro_solicitud=id.nro_solicitud) &lt;BR /&gt;		where exists (select * from &lt;BR /&gt;		Public.originacion_decision as id where &lt;BR /&gt;		ora.tipo_identificacion=id.tipo_identificacion and &lt;BR /&gt;		ora.nro_identificacion=id.nro_identificacion and &lt;BR /&gt;		ora.codigo_subproducto=id.codigo_subproducto and &lt;BR /&gt;		ora.nro_solicitud=id.nro_solicitud);&lt;BR /&gt;quit;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'll be grateful if somebody help me!&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 04:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Update-field-from-one-table-with-information-from/m-p/760208#M80888</guid>
      <dc:creator>valengvz</dc:creator>
      <dc:date>2021-08-08T04:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Update field from one table with information from another</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Update-field-from-one-table-with-information-from/m-p/760222#M80889</link>
      <description>&lt;P&gt;What are you actually trying to achieve?&lt;/P&gt;
&lt;P&gt;Based on your code the Oracle table you want to update is:&amp;nbsp;sasvi.solicitudes&lt;/P&gt;
&lt;P&gt;The table you use for the update is:&amp;nbsp;Public.originacion_decision&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your 2nd proc sort creates the 2nd table from the 1st table so you're logically updating the Oracle table with itself. Is this what you want to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just guessing: You are not using the primary key for the update so guessing you want to replace NULL values in a tuple with the populated values from the same tuple. If so then first thing to do is to formulate this SQL as exlicit pass-through SQL so that you're not moving data between Oracle and SAS.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 09:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Update-field-from-one-table-with-information-from/m-p/760222#M80889</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-08-08T09:19:54Z</dc:date>
    </item>
  </channel>
</rss>

