Consider the following sas code fragment:
%macro temp(querystr=);
filename request temp;
data _null_;
file request;
put "<string>&querystr</string>";
run;
%mend temp;
%temp(querystr="term 1" and "term2");
Note that this piece of code will not compile because the first quote in querystr will close the starting quote of the put statement when the compiler replaces querystr in the data step.
I would like to mask the quotes in the query string to transform it to a valid xml fragment, like:
<string>"term 1" and "term 2"</string>
Is there a way to output the above line to the file with proper masking of the quotation marks? I tried the %sysfunc(TranWrd()) function in combination with masking functions like %nrbquote() etc but so far I haven't found a working solution. Any help is appreciated!