<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro %bquote and unbalanced closing parenthesis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-bquote-and-unbalanced-closing-parenthesis/m-p/376166#M90253</link>
    <description>&lt;P&gt;Not seeing your whole project (and I'm fairly sure I don't want to) a kludge that might work could be to establish some special strings that are not used anywhere else in you code that are replaced in the call then swapped immediately before use such as ASCII 150 û which would not be treated as ( but could be replaced with one using the sas translate function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A kludge and fragile and maybe not suitable depending on what you are passing but...&lt;/P&gt;
&lt;PRE&gt;data example;
   probstring = "this has ( and Other ] or { problemvalues";
   encstring = translate(probstring,'ûùÿÖÜ¢','()[]{}');
   recstring = translate(encstring,'()[]{}','ûùÿÖÜ¢');
run;&lt;/PRE&gt;
&lt;P&gt;Data step examples are easier than macro but you could encode your problem value before making it the value of a parameter to a macro then in the first section of the macro decode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2017 21:56:44 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-07-14T21:56:44Z</dc:date>
    <item>
      <title>Macro %bquote and unbalanced closing parenthesis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-bquote-and-unbalanced-closing-parenthesis/m-p/376086#M90213</link>
      <description>&lt;P&gt;hi to all,&lt;/P&gt;&lt;P&gt;I use a macro to prepare webpages (html and javascript).&lt;/P&gt;&lt;PRE&gt;%macro webout(target,content,len);
  %put &amp;amp;=content;
  %if "&amp;amp;len" eq "" %then %do;
  	%let len = 200;
  %end; /* if "&amp;amp;len" eq "" */
  data tail;
    length len 8. line $&amp;amp;len str $4096;
.....
	line = str;
	output;
  run;
  proc append base=&amp;amp;target data=tail;
run;
%mend webout;&lt;/PRE&gt;&lt;P&gt;For html, it works like a charm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But there is&amp;nbsp;an issue,&amp;nbsp;if a javascript-snippet contains an unbalanced closing parenthesis:&lt;/P&gt;&lt;PRE&gt;  %webout(html,%bquote(    
                        splitArea : {show : true} 
                }] 
            }   );
  ))&lt;/PRE&gt;&lt;P&gt;The parser takes the closing parenthesis as end of %bquote.&lt;/P&gt;&lt;P&gt;Of course it works If I replace the ");" with a variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  %let cpsc = )%str(;);  /* ClosingParenthesisSemiColon */
  %webout(html,%bquote(    
                        splitArea : {show : true} 
                }] 
            } &amp;amp;cpsc
  ))&lt;/PRE&gt;&lt;P&gt;As in some cases the code-snippets are read from external files:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to do it without the workaround? Other quoting-macro or any other way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;def&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 16:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-bquote-and-unbalanced-closing-parenthesis/m-p/376086#M90213</guid>
      <dc:creator>defaz</dc:creator>
      <dc:date>2017-07-14T16:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro %bquote and unbalanced closing parenthesis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-bquote-and-unbalanced-closing-parenthesis/m-p/376136#M90243</link>
      <description>&lt;P&gt;Worth a try if you are reading the code snippet from an external file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;infile&amp;nbsp;'external.file';&lt;/P&gt;
&lt;P&gt;input code_snippet $ 32.;&lt;/P&gt;
&lt;P&gt;call symputx('snippet', code_snippet);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So bring the code snippet into a macro variable, then try calling the macro with %superq:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%webout (html, %superq(snippet) )&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 19:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-bquote-and-unbalanced-closing-parenthesis/m-p/376136#M90243</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-14T19:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro %bquote and unbalanced closing parenthesis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-bquote-and-unbalanced-closing-parenthesis/m-p/376166#M90253</link>
      <description>&lt;P&gt;Not seeing your whole project (and I'm fairly sure I don't want to) a kludge that might work could be to establish some special strings that are not used anywhere else in you code that are replaced in the call then swapped immediately before use such as ASCII 150 û which would not be treated as ( but could be replaced with one using the sas translate function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A kludge and fragile and maybe not suitable depending on what you are passing but...&lt;/P&gt;
&lt;PRE&gt;data example;
   probstring = "this has ( and Other ] or { problemvalues";
   encstring = translate(probstring,'ûùÿÖÜ¢','()[]{}');
   recstring = translate(encstring,'()[]{}','ûùÿÖÜ¢');
run;&lt;/PRE&gt;
&lt;P&gt;Data step examples are easier than macro but you could encode your problem value before making it the value of a parameter to a macro then in the first section of the macro decode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 21:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-bquote-and-unbalanced-closing-parenthesis/m-p/376166#M90253</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-14T21:56:44Z</dc:date>
    </item>
  </channel>
</rss>

