<?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: How can I  improve a proc fcmp? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427455#M105422</link>
    <description>&lt;P&gt;Can you explain what you are trying to do?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the first SAS program it seems that you want to do something then&amp;nbsp;calle=999.&lt;/P&gt;
&lt;P&gt;Is that some type of missing value code?&lt;/P&gt;
&lt;P&gt;Are you attempting to replace the 999 with some derived value?&lt;/P&gt;
&lt;P&gt;If so what is the logic for deriving the replacement value?&amp;nbsp; Can you just calculate the replacement value in advance and then conditionally use it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 13 Jan 2018 17:24:49 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-01-13T17:24:49Z</dc:date>
    <item>
      <title>How can I  improve a proc fcmp?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427188#M105332</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I passed a sql function to sas code and everything is ok, but in SQL it takes a few seconds and when I load my sas code It takes more than hour. I tried a lot of things to impruve it but anything it was ok. I don´t know what can I do more and for that reason write here. Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use Enterprise Guide 7.15 HF2 (7.100.5.6112) (64-bit).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attach 3 programs: First, the create calls the function document, and this calls to the MacroSelecionCalle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The sql function is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ALTER FUNCTION [dbo].[SeleccionaCalle_NEW]&lt;BR /&gt;(&lt;BR /&gt;-- Add the parameters for the function here&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; char(4),&lt;BR /&gt;@ArticleNr_unv int,&lt;BR /&gt;--@Padre sysname,&lt;BR /&gt;@Grade sysname,&lt;BR /&gt;@TipoColor sysname,&lt;BR /&gt;@Standard sysname,&lt;BR /&gt;@VolumenIBP float&lt;BR /&gt;)&lt;BR /&gt;RETURNS int&lt;BR /&gt;AS&lt;BR /&gt;BEGIN&lt;BR /&gt;-- Declare the return variable here&lt;BR /&gt;DECLARE @Calle int --@Calle=0 indica que no se ha encontrado calle&lt;BR /&gt;&lt;BR /&gt;-- Declaración de resto de varaibles&lt;BR /&gt;DECLARE @MaxRegla int -- Total de reglas existentes&lt;BR /&gt;DECLARE @Orden int -- Cursor de regla evaluada (de 1 a @MaxRegla)&lt;BR /&gt;DECLARE @CalleRegla int -- Calle a la que aplica la regla evaluada&lt;BR /&gt;&lt;BR /&gt;--- inicializa variables&lt;BR /&gt;SET @Calle=0; -- sólo si cumple alguna regla, se cambia el valor&lt;BR /&gt;SET @MaxRegla= (SELECT MAX(RG.Orden) FROM dbo.PT_T_SC_ReglasCalle AS RG WHERE [Enabled] = 1 and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ReglasCalle] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año)); -- Menor prioridad.&lt;BR /&gt;SET @Orden=1; -- Mayor prioridad&lt;BR /&gt;SET @CalleRegla = (SELECT RG.Calle FROM dbo.PT_T_SC_ReglasCalle AS RG WHERE Orden=@Orden and [Enabled] = 1 and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ReglasCalle] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año));&lt;BR /&gt;SET @TipoColor = LTRIM(@TipoColor)&lt;BR /&gt;&lt;BR /&gt;-- iterar hasta que una calle cumpla o se acaben las reglas.&lt;BR /&gt;&lt;BR /&gt;WHILE @Orden &amp;lt;= @MaxRegla and @Calle=0&lt;BR /&gt;BEGIN&lt;BR /&gt;-- Verificar si existe el padre&lt;BR /&gt;--IF (select COUNT(*) from dbo.PT_T_SC_ListaPadres where Calle=@CalleRegla and Padre=@Padre and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ListaPadres] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))&amp;gt;0&lt;BR /&gt;IF (select COUNT(*) from dbo.PT_T_SC_ListaPadres where Calle=@CalleRegla and articleNr_unv=@ArticleNr_unv and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ListaPadres] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))&amp;gt;0&lt;BR /&gt;BEGIN&lt;BR /&gt;-- Existe un Padre producido con anteriordad en esta calle&lt;BR /&gt;-- Es Standard?&lt;BR /&gt;-- 13/01/2014 DaniReseco: Saco los comentarios de la validacion de standard y volumen&lt;BR /&gt;-- email Rocio 13/01/2014&lt;BR /&gt;IF @Standard='Standard'&lt;BR /&gt;SET @Calle = @CalleRegla&lt;BR /&gt;ELSE&lt;BR /&gt;-- No es standard&lt;BR /&gt;-- Es superior al Volumen mínimo?&lt;BR /&gt;IF (SELECT RG.LotMin FROM dbo.PT_T_SC_ReglasCalle AS RG WHERE Orden=@Orden and [Enabled] = 1 and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ReglasCalle] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))&amp;lt;=@VolumenIBP SET @Calle=@CalleRegla&lt;BR /&gt;END&lt;BR /&gt;ELSE&lt;BR /&gt;-- Este Padre no existe en esta regla de calle&lt;BR /&gt;BEGIN&lt;BR /&gt;-- Verificar si Existe Grade asignado a la calle&lt;BR /&gt;IF (select COUNT(*) from dbo.PT_T_SC_ListaGrades where Calle=@CalleRegla and Grade=@Grade and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ListaGrades] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))&amp;gt;0&lt;BR /&gt;BEGIN&lt;BR /&gt;-- Existe grade disponible en esta calle&lt;BR /&gt;-- Validar si Cualquier TipoColor&lt;BR /&gt;IF (SELECT RG.AllTipoColor FROM dbo.PT_T_SC_ReglasCalle AS RG WHERE Orden=@Orden and [Enabled] = 1 and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ReglasCalle] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))=-1&lt;BR /&gt;BEGIN&lt;BR /&gt;-- Cualquier tipo Color&lt;BR /&gt;-- Validar si es standard&lt;BR /&gt;IF @Standard='Standard' SET @Calle = @CalleRegla&lt;BR /&gt;ELSE&lt;BR /&gt;-- No es standard&lt;BR /&gt;-- Es superior al Volumen mínimo?&lt;BR /&gt;IF (SELECT RG.LotMin FROM dbo.PT_T_SC_ReglasCalle AS RG WHERE Orden=@Orden and [Enabled] = 1 and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ReglasCalle] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))&amp;lt;=@VolumenIBP SET @Calle=@CalleRegla&lt;BR /&gt;END&lt;BR /&gt;ELSE&lt;BR /&gt;-- No está marcado cualquier TipoColor&lt;BR /&gt;-- Validar si existe TipoColor en esta Calle&lt;BR /&gt;IF (select COUNT(*) from dbo.PT_T_SC_ListaTipoColor where Calle=@CalleRegla and TipoColor=@TipoColor and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ListaTipoColor] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))&amp;gt;0&lt;BR /&gt;BEGIN&lt;BR /&gt;-- Existe Este tipoColor en esta Calle&lt;BR /&gt;-- Validar si es standard&lt;BR /&gt;IF @Standard='Standard' SET @Calle = @CalleRegla&lt;BR /&gt;ELSE&lt;BR /&gt;-- No es standard&lt;BR /&gt;-- Es superior al Volumen mínimo?&lt;BR /&gt;IF (SELECT RG.LotMin FROM dbo.PT_T_SC_ReglasCalle AS RG WHERE Orden=@Orden and [Enabled] = 1 and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ReglasCalle] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))&amp;lt;=@VolumenIBP SET @Calle=@CalleRegla&lt;BR /&gt;END&lt;BR /&gt;END&lt;BR /&gt;END&lt;BR /&gt;SET @Orden=@Orden+1&lt;BR /&gt;SET @CalleRegla = (SELECT RG.Calle FROM dbo.PT_T_SC_ReglasCalle AS RG WHERE Orden=@Orden and [Enabled] = 1 and Año = (SELECT min([Año]) FROM [PricingTool].[dbo].[PT_T_SC_ReglasCalle] where &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114691"&gt;@ano&lt;/a&gt; &amp;lt;= Año))&lt;BR /&gt;END&lt;BR /&gt;-- Return the result of the function&lt;BR /&gt;RETURN @Calle;&lt;BR /&gt;&lt;BR /&gt;END&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 13:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427188#M105332</guid>
      <dc:creator>zetitas</dc:creator>
      <dc:date>2018-01-12T13:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I  improve a proc fcmp?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427197#M105337</link>
      <description>&lt;P&gt;I am sorry, I can't even ascertain what the question is from this mass of impossible to read text and attached files?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suppose one place to start is why you are creating compiled procedures in the first place?&amp;nbsp; Personally I find compiled procedures to be a bad thing, first your hiding code elsewhere, then compiling it so that its not available to the user and in a propretary file format which likely wont work in the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your working with a database, then use some simple SQL steps to extract into SAS the data you want to work with.&amp;nbsp; Once it is in SAS then use Base SAS programming to work with the data.&amp;nbsp; Passing processing backwards and forwards, and using compiled SAS procedures to run SQL based queries is bound to take more time and just creates a complex web of relationships.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 14:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427197#M105337</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-12T14:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I  improve a proc fcmp?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427309#M105366</link>
      <description>&lt;P&gt;I am not sure that i understand your question, but i can see in your DATA step that you call your FCMP function.&amp;nbsp; That function calls your macro and that macro (M_SeleccionaCalle), which in turn executes a number of data reads (potentially lots of I/O).&amp;nbsp; All of this I/O will happen for every observation in the original incoming data set (PT_V_NEW_SALES_LOTE_ORDER_TEMP1).&amp;nbsp; Without understanding your intent/objective/logic, my first thought is to try to minimize all of this I/O.&amp;nbsp; Can you restructure so that the macro (M_SeleccionaCalle) is called only once instead of N times?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 18:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427309#M105366</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2018-01-12T18:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I  improve a proc fcmp?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427442#M105413</link>
      <description>I´ll think about it and I´ll try to work with SAS data. Thank you!!!!</description>
      <pubDate>Sat, 13 Jan 2018 11:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427442#M105413</guid>
      <dc:creator>zetitas</dc:creator>
      <dc:date>2018-01-13T11:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I  improve a proc fcmp?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427443#M105414</link>
      <description>I´ll think about it and I´ll try to work with less I/O. Thank you very much!!!!</description>
      <pubDate>Sat, 13 Jan 2018 11:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427443#M105414</guid>
      <dc:creator>zetitas</dc:creator>
      <dc:date>2018-01-13T11:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I  improve a proc fcmp?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427455#M105422</link>
      <description>&lt;P&gt;Can you explain what you are trying to do?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the first SAS program it seems that you want to do something then&amp;nbsp;calle=999.&lt;/P&gt;
&lt;P&gt;Is that some type of missing value code?&lt;/P&gt;
&lt;P&gt;Are you attempting to replace the 999 with some derived value?&lt;/P&gt;
&lt;P&gt;If so what is the logic for deriving the replacement value?&amp;nbsp; Can you just calculate the replacement value in advance and then conditionally use it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 17:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427455#M105422</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-13T17:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I  improve a proc fcmp?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427460#M105424</link>
      <description>It´s a some type of missing value code that I replace with 999 when is missing. And for each 999value I have to call the function to return a correct value. The problem is the function does a lot of consults to db sql. I took every tables and I passed them to work library and It´s take 5 minutes!! Already everything is alright and thank you for answer me!</description>
      <pubDate>Sat, 13 Jan 2018 18:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-improve-a-proc-fcmp/m-p/427460#M105424</guid>
      <dc:creator>zetitas</dc:creator>
      <dc:date>2018-01-13T18:38:16Z</dc:date>
    </item>
  </channel>
</rss>

