title: Cant get return value from user defined functions in SAS
body: <p>I have a function which calls a SAS macro that is responsible for making a call to an API and get your answer. This function is called from a step data, passing a parameter.</p>
  
  <p>The whole process works properly, except I can not get the response value in datastep.</p>
  
  <p>If I run the macro separately, I can write to the log the API response, so I understand should be able to return to my datastep.</p>
  
  <p>Any ideas?</p>
  
  <p>Here is the code</p>
  
  <p><strong>Macro</strong></p>
  
  <pre><code>%macro acortador();
  %put &amp;url_larga;
  
  data _null_;
   length url $ 2048;
   url = catt(
   'http:XXXXXX',urlencode(trimn(&amp;url_larga)));  
   call symputx('REQUEST_URL', url);
   run;
  
   %put &amp;REQUEST_URL;
  
  /* API request */
  filename out "XXXXXXXX.xml";
  
  proc http 
      out=out         
      url= "%superq(REQUEST_URL)"
      method="get";
  run;
  
  /* response xml */
  filename data 'XXXXXXX.xml';
  
  data _null_;
      infile data lrecl = 32000 truncover scanover;
          input                       
              @"&lt;status&gt;" shorturl $255. @@;
          shorturl = substr(shorturl,1,index(shorturl,'&lt;/')-1);   
          call symputx('r', shorturl);
  run;
  
   %put &amp;r;
  
  %mend acortador;
  </code></pre>
  
  <p><strong>Function</strong></p>
  
  <pre><code>proc fcmp outlib=work.funcs.test;
  function acortador(url_larga $) $ 300;
   rc = run_macro('acortador', url_larga, r);
    return (r);
  endsub;
  quit;
  
  options cmplib=work.funcs;
  </code></pre>
  
  <p><strong>Datastep</strong></p>
  
  <pre><code>data test;  
      set work.origin_table;
      r = acortador(some_parameter);  
  run;
  </code></pre>