Dear All,
I am working for customer, where customer is not given direct access to databases. So, provided the API to fetch the data. In the process, same api i need to call for each well. so , I have written the macro. so for the one the well name has specical character (/) i.e x-xx-xxx-x/x so when i am passing the macro parmeter, it is resolving to x-xx-xxx-x/x as there is forward slash in the well name, it treating url is different and throwing the error. I used the function urlencode funtion it is throwing the error or process is continue to run..without giving any error or data
Proc https
url="https://xxxxxxxxx/xxxx/xxxx/ x-xx-xxx-x/x/xxxxxxxxx"
method='GET'
out=testing;
run;
Proc https
url="https://xxxxxxxxx/xxxx/xxxx/ urlencode(x-xx-xxx-x/x)/xxxxxxxxx"
method='GET'
out=testing;
run;
Thank you,
Narahari
All URLENCODE() will do is convert the slash into %2F.
Does it work if you convert the / into %2F in the call?
Try it with a specific file.
If it works then here is how you can call URLENCODE(). Either do it for real in a data step.
Or call with %SYSFUNC() in macro code.
245 data test; 246 string='x-xx-xxx-x/x'; 247 ustring=urlencode(trim(string)); 248 put (_all_) (= :$quote.); 249 run; string="x-xx-xxx-x/x" ustring="x-xx-xxx-x%2Fx" NOTE: The data set WORK.TEST has 1 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds 250 251 %let string=x-xx-xxx-x/x ; 252 %put &=string -> %sysfunc(urlencode(&string)) ; STRING=x-xx-xxx-x/x -> x-xx-xxx-x%2Fx
how about this.
data _null_;
call symputx('url','https://xxxxxxxxx/xxxx/xxxx/'||trim(urlencode('x-xx-xxx-x/x'))||'/xxxxxxxxx');
run;
Proc http url="&url"
method='GET'
out=testing;
run;
All URLENCODE() will do is convert the slash into %2F.
Does it work if you convert the / into %2F in the call?
Try it with a specific file.
If it works then here is how you can call URLENCODE(). Either do it for real in a data step.
Or call with %SYSFUNC() in macro code.
245 data test; 246 string='x-xx-xxx-x/x'; 247 ustring=urlencode(trim(string)); 248 put (_all_) (= :$quote.); 249 run; string="x-xx-xxx-x/x" ustring="x-xx-xxx-x%2Fx" NOTE: The data set WORK.TEST has 1 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds 250 251 %let string=x-xx-xxx-x/x ; 252 %put &=string -> %sysfunc(urlencode(&string)) ; STRING=x-xx-xxx-x/x -> x-xx-xxx-x%2Fx
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.