BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
harigottala0
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

View solution in original post

2 REPLIES 2
japelin
Rhodochrosite | Level 12

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;
Tom
Super User Tom
Super User

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 537 views
  • 0 likes
  • 3 in conversation