<?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 Error updating table vía set/modify key= in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-updating-table-v%C3%ADa-set-modify-key/m-p/216588#M39914</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a master table called ventas that I want to update based on a lookup table called producto, the field to combine datasets is cod_producto.&lt;/P&gt;&lt;P&gt;I want to update the rows of ventas in which ventas.cod_producto = productos.cod_producto I am doing a set + modify key= and it doesn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let fecha_ini = %sysevalf(%sysfunc(date()) - 900);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put fecha_ini = &amp;amp;fecha_ini;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Crearting dataset ventas */&lt;/P&gt;&lt;P&gt;data ventas(drop=i);&lt;/P&gt;&lt;P&gt;do i=1 to 10000000;&lt;/P&gt;&lt;P&gt;fecha = &amp;amp;fecha_ini + round(900*ranuni(1));&lt;/P&gt;&lt;P&gt;cod_producto = compress('P'||(round(ranuni(1)*1000)+1));&lt;/P&gt;&lt;P&gt;cod_centro = compress('C'||round(ranuni(1)*100));&lt;/P&gt;&lt;P&gt;hc_unidades = round(ranuni(1)*9) + 1;&lt;/P&gt;&lt;P&gt;format fecha ddmmyyn8.;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;/* Crearting dataset ventas */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data productos(drop=i);&lt;/P&gt;&lt;P&gt;do i = 1 to 1001;&lt;/P&gt;&lt;P&gt;cod_producto = compress('P'||i);&lt;/P&gt;&lt;P&gt;hc_precio = round(ranuni(1)*400) + 100;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Updating datasets ventas */&lt;/P&gt;&lt;P&gt;data ventas;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set productos;&amp;nbsp; /* lookpup */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; modify ventas key=cod_producto;&amp;nbsp;&amp;nbsp; /* master */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _iorc_ = 0 then do; /* hay coincidencia */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hc_ventas = hc_unidades*hc_precio;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hc_ventas = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;'No defined variables for file ventas'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody help me??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Jun 2015 22:49:41 GMT</pubDate>
    <dc:creator>juanvg1972</dc:creator>
    <dc:date>2015-06-29T22:49:41Z</dc:date>
    <item>
      <title>Error updating table vía set/modify key=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-updating-table-v%C3%ADa-set-modify-key/m-p/216588#M39914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a master table called ventas that I want to update based on a lookup table called producto, the field to combine datasets is cod_producto.&lt;/P&gt;&lt;P&gt;I want to update the rows of ventas in which ventas.cod_producto = productos.cod_producto I am doing a set + modify key= and it doesn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let fecha_ini = %sysevalf(%sysfunc(date()) - 900);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put fecha_ini = &amp;amp;fecha_ini;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Crearting dataset ventas */&lt;/P&gt;&lt;P&gt;data ventas(drop=i);&lt;/P&gt;&lt;P&gt;do i=1 to 10000000;&lt;/P&gt;&lt;P&gt;fecha = &amp;amp;fecha_ini + round(900*ranuni(1));&lt;/P&gt;&lt;P&gt;cod_producto = compress('P'||(round(ranuni(1)*1000)+1));&lt;/P&gt;&lt;P&gt;cod_centro = compress('C'||round(ranuni(1)*100));&lt;/P&gt;&lt;P&gt;hc_unidades = round(ranuni(1)*9) + 1;&lt;/P&gt;&lt;P&gt;format fecha ddmmyyn8.;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;/* Crearting dataset ventas */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data productos(drop=i);&lt;/P&gt;&lt;P&gt;do i = 1 to 1001;&lt;/P&gt;&lt;P&gt;cod_producto = compress('P'||i);&lt;/P&gt;&lt;P&gt;hc_precio = round(ranuni(1)*400) + 100;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Updating datasets ventas */&lt;/P&gt;&lt;P&gt;data ventas;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set productos;&amp;nbsp; /* lookpup */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; modify ventas key=cod_producto;&amp;nbsp;&amp;nbsp; /* master */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _iorc_ = 0 then do; /* hay coincidencia */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hc_ventas = hc_unidades*hc_precio;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hc_ventas = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;'No defined variables for file ventas'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody help me??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2015 22:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-updating-table-v%C3%ADa-set-modify-key/m-p/216588#M39914</guid>
      <dc:creator>juanvg1972</dc:creator>
      <dc:date>2015-06-29T22:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Error updating table vía set/modify key=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-updating-table-v%C3%ADa-set-modify-key/m-p/216589#M39915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to create an index before using&amp;nbsp; modify&amp;nbsp;&amp;nbsp;&amp;nbsp; key= .&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; create index cod_producto on ventas;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2015 09:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-updating-table-v%C3%ADa-set-modify-key/m-p/216589#M39915</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-06-30T09:35:40Z</dc:date>
    </item>
  </channel>
</rss>

