<?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: Is it possible to create user defined functions using the SQL query node of the Data Management in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459947#M14237</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt; oh he mentioned SQL Server as an example were you can create functions - got me confused....</description>
    <pubDate>Fri, 04 May 2018 06:25:35 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2018-05-04T06:25:35Z</dc:date>
    <item>
      <title>Is it possible to create user defined functions using the SQL query node of the Data Management Stud</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/457620#M14160</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got a data job where I need to validate tax codes. I know I can do this by using the expression node after the sql query node. But for my specific needs, which I can't elaborate here, I need to create a function in the database that I use as source. So is it possible to use the create function statement in the sql query node.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I don't have access to the actual database, only through Data Connection in the Data Management Studio&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 07:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/457620#M14160</guid>
      <dc:creator>smicha</dc:creator>
      <dc:date>2018-04-26T07:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/458030#M14173</link>
      <description>&lt;P&gt;How about you explain what you mean by "validate tax codes" because if you can't explain what you want we can't possibly provide a good solution. If for security reasons you can't provide the real codes you want to validate, make up an imaginary example that accurately describes what you want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, let's say you wanted to validate a 1 character variable called Gender so that it is only able to hold the values M for Male, F for Female or blank. Please explain what you want like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also what is the database that holds the data you want to validate?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 07:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/458030#M14173</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-04-27T07:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/458032#M14174</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you for your answer. In database management systems (Microsoft SQL Server) you can create your own functions. The thing that I am asking is not that you provide the solution for my task (validate tax codes), but if the Data Management Studio 's query node or SQL Execute Node can create functions in the database that my data are residing. DB Version is DB2.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;Spyros&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Apr 2018 07:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/458032#M14174</guid>
      <dc:creator>smicha</dc:creator>
      <dc:date>2018-04-27T07:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/458033#M14175</link>
      <description>&lt;P&gt;If you can write it in DB2's flavour of SQL, then you can run it in SAS using SQL PASSTHRU using the EXECUTE statement. I suspect that is what the SQL Execute Node does.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 07:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/458033#M14175</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-04-27T07:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459215#M14227</link>
      <description>&lt;P&gt;As it seems you can't create a function using the SQL Execute Node, I get error: QSYS.{username} &amp;nbsp;IS AN UNDEFINED NAME.&amp;nbsp; TABLE (-204). I haven't find any other solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Edit 10/05 :&lt;/STRONG&gt; By "i haven't find any other solution" i mean that i haven't any other solution to create a UDF function into the database by using Data Management Alone. Sorry for the inconvenience.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 13:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459215#M14227</guid>
      <dc:creator>smicha</dc:creator>
      <dc:date>2018-05-10T13:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459499#M14230</link>
      <description>&lt;P&gt;I suggest you open a track with SAS Tech Support on this issue. Also you could try this just using SQL PASSTHRU outside of SAS Data Management.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 22:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459499#M14230</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-05-02T22:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459536#M14231</link>
      <description>I don't understand "PS: I don't have access to the actual database, only through Data Connection in the Data Management Studio".&lt;BR /&gt;You should be able to use the same credentials in your connection to logon to SQL Server Management Studio.</description>
      <pubDate>Thu, 03 May 2018 04:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459536#M14231</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-05-03T04:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459856#M14235</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;- the OP says he is using DB2, unless I'm misinterpreting his posts.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 21:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459856#M14235</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-05-03T21:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459947#M14237</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt; oh he mentioned SQL Server as an example were you can create functions - got me confused....</description>
      <pubDate>Fri, 04 May 2018 06:25:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/459947#M14237</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-05-04T06:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create user defined functions using the SQL query node of the Data Management</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/460362#M14259</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can either use one user defined function in the SQL query node if it has been created within MS SQL Server, or create your proper user defined function to be used in the expression language node (EEL). For that last option, you only need to edit your UDF into one text file to be copied into the etc/udf folder of your dm studio or server install. Please find below&amp;nbsp;fex examples:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--&amp;gt; mind that you can encapsulate functions but the one called would have to exist before the caller.&lt;/P&gt;
&lt;P&gt;--&amp;gt; for udf/changed to be taken into you will have to restart dm studio or your server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Function:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nvl&lt;BR /&gt;// Description:&amp;nbsp;&amp;nbsp; Replace null in parameter1 with value in parameter2&lt;BR /&gt;// Inputs:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Field to test&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; replacement value if null&lt;BR /&gt;// Output:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Field with value replacing null&lt;BR /&gt;function nvl return String&lt;BR /&gt;String nvlString&lt;BR /&gt;if isnull(parameter(1)) then nvlString=parameter(2) else nvlString=parameter(1)&lt;BR /&gt;return nvlString&lt;BR /&gt;end function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Function:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rtrim&lt;BR /&gt;// Description:&amp;nbsp;&amp;nbsp; Trim trailing characters in parameter2 from parameter1&lt;BR /&gt;// Inputs:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Field to trim&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; character to remove&lt;BR /&gt;// Output:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Trimmed Field&lt;BR /&gt;function rtrim return String&lt;BR /&gt;String rString&lt;BR /&gt;String cString&lt;BR /&gt;if isnull(parameter(1)) or isnull(parameter(2)) then rString=null&lt;BR /&gt;else&lt;BR /&gt;begin&lt;BR /&gt;&amp;nbsp; rString=parameter(1)&lt;BR /&gt;&amp;nbsp; cString=parameter(2)&lt;BR /&gt;&amp;nbsp; while right(rString,len(cstring))==cString&lt;BR /&gt;&amp;nbsp;&amp;nbsp; rString=left(rString,len(rString)-len(cString))&lt;BR /&gt;end&lt;BR /&gt;return rString&lt;BR /&gt;end function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Function:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ltrim&lt;BR /&gt;// Description:&amp;nbsp;&amp;nbsp; Trim leading characters in parameter2 from parameter1&lt;BR /&gt;// Inputs:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Field to trim&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; character to remove&lt;BR /&gt;// Output:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Trimmed Field&lt;BR /&gt;function ltrim return String&lt;BR /&gt;String rString&lt;BR /&gt;String cString&lt;BR /&gt;if isnull(parameter(1)) or isnull(parameter(2)) then rString=null&lt;BR /&gt;else&lt;BR /&gt;begin&lt;BR /&gt;&amp;nbsp; rString=parameter(1)&lt;BR /&gt;&amp;nbsp; cString=parameter(2)&lt;BR /&gt;&amp;nbsp; while left(rString,len(cstring))==cString&lt;BR /&gt;&amp;nbsp;&amp;nbsp; rString=right(rString,len(rString)-len(cString))&lt;BR /&gt;end&lt;BR /&gt;return rString&lt;BR /&gt;end function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;//This function calculates ISIN check digits using the "Modulus 10 Double Add //&lt;BR /&gt;//Double" technique used in CUSIPs //&lt;BR /&gt;// &lt;A href="http://en.wikipedia.org/wiki/International_Securities_Identifying_Number" target="_blank"&gt;http://en.wikipedia.org/wiki/International_Securities_Identifying_Number&lt;/A&gt; //&lt;BR /&gt; &lt;BR /&gt;// Author: Vincent Rejany //&lt;BR /&gt;// Version: 1.0 //&lt;BR /&gt;// Creation date: 20130304 //&lt;BR /&gt;// Modificationdate: //&lt;BR /&gt;// //&lt;BR /&gt;//////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;
&lt;P&gt;//////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// Function: udfCheckIsin //&lt;BR /&gt;// Description: //&lt;BR /&gt;// Input: 1 string //&lt;BR /&gt;// Output: 1 boolean // &lt;BR /&gt;//////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;
&lt;P&gt;Function udfCheckIsin return boolean&lt;/P&gt;
&lt;P&gt;string ISINi&lt;BR /&gt;string ISINc&lt;BR /&gt;string ISINa&lt;BR /&gt;integer ISINd&lt;BR /&gt;integer ISINs&lt;BR /&gt;integer i&lt;BR /&gt;boolean udfCheckIsin&lt;/P&gt;
&lt;P&gt;ISINi = parameter(1)&lt;BR /&gt;ISINs = 0&lt;BR /&gt;udfCheckIsin = false&lt;/P&gt;
&lt;P&gt;if len(ISINi) != 12 then&lt;BR /&gt; udfCheckIsin = false&lt;BR /&gt;else&lt;BR /&gt; begin&lt;BR /&gt; //Remove check digit&lt;BR /&gt; ISINc = left(ISINi,11)&lt;/P&gt;
&lt;P&gt;//Convert any letters to numbers&lt;BR /&gt; ISINc = replace(ISINc,'A','10',0) ISINc = replace(ISINc,'B','11',0) ISINc = replace(ISINc,'C','12',0)&lt;BR /&gt; ISINc = replace(ISINc,'D','13',0) ISINc = replace(ISINc,'E','14',0) ISINc = replace(ISINc,'F','15',0)&lt;BR /&gt; ISINc = replace(ISINc,'G','16',0) ISINc = replace(ISINc,'H','17',0) ISINc = replace(ISINc,'I','18',0)&lt;BR /&gt; ISINc = replace(ISINc,'J','19',0) ISINc = replace(ISINc,'K','20',0) ISINc = replace(ISINc,'L','21',0)&lt;BR /&gt; ISINc = replace(ISINc,'M','22',0) ISINc = replace(ISINc,'N','23',0) ISINc = replace(ISINc,'O','24',0)&lt;BR /&gt; ISINc = replace(ISINc,'P','25',0) ISINc = replace(ISINc,'Q','26',0) ISINc = replace(ISINc,'R','27',0)&lt;BR /&gt; ISINc = replace(ISINc,'S','28',0) ISINc = replace(ISINc,'T','29',0) ISINc = replace(ISINc,'U','30',0)&lt;BR /&gt; ISINc = replace(ISINc,'V','31',0) ISINc = replace(ISINc,'W','32',0) ISINc = replace(ISINc,'X','33',0)&lt;BR /&gt; ISINc = replace(ISINc,'Y','34',0) ISINc = replace(ISINc,'Z','35',0)&lt;/P&gt;
&lt;P&gt;/*&lt;BR /&gt; //Fill Array from right to left &lt;BR /&gt; for i = ISINd to 1 step -1&lt;BR /&gt; begin&lt;BR /&gt; ISINa = ISINa &amp;amp; mid(ISINc, i, 1)&lt;BR /&gt; end&lt;BR /&gt;*/&lt;BR /&gt; &lt;BR /&gt; ISINd = len(ISINc)&lt;BR /&gt; ISINa = ISINc&lt;BR /&gt; &lt;BR /&gt; //Sum characters&lt;BR /&gt; for i = 1 to ISINd&lt;BR /&gt; begin&lt;BR /&gt; if i % 2 then&lt;BR /&gt; begin&lt;BR /&gt; if mid(ISINa,i) &amp;lt; 5 then &lt;BR /&gt; ISINs = ISINs + mid(ISINa,i,1)*2&lt;BR /&gt; else&lt;BR /&gt; ISINs = ISINs + mid(ISINa,i,1)*2-9&lt;BR /&gt; end&lt;BR /&gt; else&lt;BR /&gt; ISINs = ISINs + mid(ISINa,i,1)&lt;BR /&gt; end&lt;BR /&gt; &lt;BR /&gt; //Check digit validation&lt;BR /&gt; if (10 - (ISINs % 10)) % 10 == right(ISINi,1)&lt;BR /&gt; udfCheckIsin = true&lt;/P&gt;
&lt;P&gt;end&lt;/P&gt;
&lt;P&gt;return udfCheckIsin&lt;/P&gt;
&lt;P&gt;End Function&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 07:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-create-user-defined-functions-using-the-SQL/m-p/460362#M14259</guid>
      <dc:creator>VincentRejany</dc:creator>
      <dc:date>2018-05-07T07:46:19Z</dc:date>
    </item>
  </channel>
</rss>

