<?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: call routine vs function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257963#M49591</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I pretty much use call missing function when I have to set to missing both character and numeric variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example when I use hash and have previously loaded variables using set, I find useful call missing rather then missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Consider the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;if 0 then set have hash1;&lt;BR /&gt;&lt;BR /&gt;if _N_=1 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;declare hash a(dataset: "hash1");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;a.definekey('key');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;a.definedata('num1', 'num2', 'num3', 'char1', 'char2', 'char3');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;a.definedone();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&lt;BR /&gt;set have;&lt;BR /&gt;&lt;BR /&gt;if a.find() ne 0 then call missing(num1, num2, num3, char1, char2, char3);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Mar 2016 14:16:42 GMT</pubDate>
    <dc:creator>Loko</dc:creator>
    <dc:date>2016-03-21T14:16:42Z</dc:date>
    <item>
      <title>call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257951#M49584</link>
      <description>&lt;P&gt;Under what situations CALL ROUTINE is used over SAS functions such as CALL SCAN vs. SCAN?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 13:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257951#M49584</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-21T13:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257955#M49585</link>
      <description>&lt;P&gt;From the documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001131396.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001131396.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To try and put it another way, call &amp;lt;function&amp;gt; does something, but doesn't necessarily assign a result. &amp;nbsp;Lok at the examples in the documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002255934.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002255934.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You will see that call scan is executed, but is not assigned to anything e.g.:&lt;/P&gt;
&lt;P&gt;abc=scan(...);&lt;/P&gt;
&lt;P&gt;call scan(...);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first example assigns the result to abc, the second just executes the function, no return.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 13:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257955#M49585</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-21T13:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257962#M49590</link>
      <description>&lt;P&gt;My general rule of thumb is to use the function when possible.&amp;nbsp; The CALL routines can do more, but the functions can do the most commonly required tasks.&amp;nbsp; So switch to the CALL routine when you need something a little more complex than what the function can do.&amp;nbsp; By using the functions when possible, you can use a simpler program at the cost of having slightly less functionality available.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 14:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257962#M49590</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-21T14:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257963#M49591</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I pretty much use call missing function when I have to set to missing both character and numeric variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example when I use hash and have previously loaded variables using set, I find useful call missing rather then missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Consider the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;if 0 then set have hash1;&lt;BR /&gt;&lt;BR /&gt;if _N_=1 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;declare hash a(dataset: "hash1");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;a.definekey('key');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;a.definedata('num1', 'num2', 'num3', 'char1', 'char2', 'char3');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;a.definedone();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&lt;BR /&gt;set have;&lt;BR /&gt;&lt;BR /&gt;if a.find() ne 0 then call missing(num1, num2, num3, char1, char2, char3);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 14:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257963#M49591</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-03-21T14:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257973#M49598</link>
      <description>&lt;P&gt;Thank you, all.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 14:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257973#M49598</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-21T14:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257987#M49607</link>
      <description>&lt;P&gt;I was looking at this example in SAS doc. So CALL SCAN is able to create variables from its arguments (position, length) without specifying those variables explicitly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data artists;
   input string $60.;
   drop string;
   do i=1 to 99;
      call scan(string, i, position, length);
      if not position then leave;
      Name=substrn(string, position, length);
      output;
   end;
   datalines;
Picasso Toulouse-Lautrec Turner "Van Gogh" Velazquez
;

proc print data=artists;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 15:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257987#M49607</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-21T15:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257993#M49608</link>
      <description>&lt;P&gt;SAS always creates new variables when you reference a name that it has not seen before. &amp;nbsp;That has nothing to do with CALL SCAN().&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 16:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/257993#M49608</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-03-21T16:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/258057#M49633</link>
      <description>&lt;P&gt;I looked closely at the arugments of the CALL SCAN. It makes sense now. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 19:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/258057#M49633</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-21T19:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: call routine vs function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/258566#M49832</link>
      <description>&lt;P&gt;This example may further your understanding. &amp;nbsp;It looks for a string that is all uppercase and 2 bytes long. &amp;nbsp;Using call scan I find the position and length of each uppercase&amp;nbsp;string. &amp;nbsp;if length eq 2. &amp;nbsp;substring the target from p for l. &amp;nbsp;Using SCAN function you would have to measure the result returned from SCAN. &amp;nbsp;Same but different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _2upcase;
   input string $50.;
   do c=1 by 1 until(l eq 2 or p eq 0);
      call scan(strip(string),c,p,l,,'ldsp');
      end;
   length _2upcase $2;
   _2upcase = substrn(string,p,l);
   cards;
nndkd11UUndkdLLL
kdnakaliueoina
nnnlllLLLlllLLlll
thisISa2DIgit
this IS silly
this.IS.silly
;;;;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I reckon this could be replaced with a one line RegEX but that's another topic.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 15:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-routine-vs-function/m-p/258566#M49832</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-03-23T15:40:01Z</dc:date>
    </item>
  </channel>
</rss>

