I have the following code which fails if users have the character '&' in their password (myPW).
I know that data _null_ statement is working as expected 'input' is resolving to the correct string. The problem seems to be in the 'in=' statement in proc http. How do I make sure that the correct string is being input in proc http?
filename input TEMP;
filename resp TEMP;
filename headers TEMP;
%LET myPW=%STR(xxxxxx);
%LET myID=%STR(xxxxxx);
data _null_;
file input recfm=f lrecl=1;
put "RS_action=signOn%nrstr(&RS_userName)=&myID.%nrstr(&RS_password)=&myPW";
run;
proc http
method="POST"
url="http://xxxxx:####"
in=input
headerout=headers
out=resp
HEADEROUT_OVERWRITE;
run;
SAS version 9.4
The use URLENCODE() function to convert the string before writing it.
Or possible you want the HTMLENCODE() function instead.
You need to show what you think the resulting text should look like.
If you want to use & in your strings without SAS thinking you want to reference a macro variable then why not just use single quotes?
Also not sure how you expect SAS write such a long string to a file that has records of only 1 byte each?
%LET myPW=%STR(xxxxxx);
%LET myID=%STR(xxxxxx);
data _null_;
file input ;
put 'RS_action=signOn&RS_userName=' "&myID." '&RS_password=' "&myPW";
run;
Thank you for the reply.
It gives me the same result as the original code. It works for passwords that do not have '&' character, but fails if the password has that character. When I look at 'input', the password is resolving correctly though.
The use URLENCODE() function to convert the string before writing it.
Or possible you want the HTMLENCODE() function instead.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: