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. The whole process works properly, except I can not get the response value in datastep. 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. Any ideas? Here is the code: Macro %macro acortador();
%put &url_larga;
data _null_;
length url $ 2048;
url = catt(
'http:XXXXXX',urlencode(trimn(&url_larga)));
call symputx('REQUEST_URL', url);
run;
%put &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
@"<status>" shorturl $255. @@;
shorturl = substr(shorturl,1,index(shorturl,'</')-1);
call symputx('r', shorturl);
run;
%put &r;
%mend acortador; Function proc fcmp outlib=work.funcs.test;
function acortador(url_larga $) $ 300;
rc = run_macro('acortador', url_larga, r);
return (r);
endsub;
quit; Datastep options cmplib=work.funcs;
data test;
set work.origin_table;
r = acortador(some_parameter);
run;
... View more