<?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: ODS TEXT with macro variable containing %-sign inside in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329400#M17859</link>
    <description>&lt;P&gt;hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are the HTMLENCODE / HTMLDECODE functions, but they&amp;nbsp;will not encode the % sign, they will others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2017 12:38:32 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2017-02-02T12:38:32Z</dc:date>
    <item>
      <title>ODS TEXT with macro variable containing %-sign inside</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329314#M17856</link>
      <description>&lt;P&gt;Once again I have struggled with an issue for ages, and could find an exact answer anywhere.&lt;/P&gt;
&lt;P&gt;So my problem is that I need to use a macro variable inside ODS TEXT statement. The unfortunate part is that the macro variable could contain %-sign and it causes whole lot of issues. I have tried literally every trick I know and beyound.&lt;/P&gt;
&lt;P&gt;Everything is fine when I use %SUPERQ with the macro variable, but when I do that in ODS TEXT it has no effect. I have attached a small example what I have trying to achieve.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing;
text='Some text %and some more';
call symput('mvar',text);
run;

%*Works like a charm;
%put %superq(mvar);

%*None of these work;
ods html;
ods text="&amp;lt;p class=""bold""&amp;gt;%superq(mvar)&amp;lt;/p&amp;gt;";

%*This is not even possible?;
/*ods text=%nrbquote("&amp;lt;p class=""bold""&amp;gt;%superq(mvar)&amp;lt;/p&amp;gt;");*/

ods text=%nrstr("&amp;lt;p class=""bold""&amp;gt;%superq(mvar)&amp;lt;/p&amp;gt;");

ods text="&amp;lt;p class=""bold""&amp;gt;""&amp;amp;mvar.""&amp;lt;/p&amp;gt;";

ods html close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Feb 2017 08:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329314#M17856</guid>
      <dc:creator>BobHope</dc:creator>
      <dc:date>2017-02-02T08:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: ODS TEXT with macro variable containing %-sign inside</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329328#M17857</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this is not really &amp;nbsp;SAS macro related, but rather the %A is somehow&amp;nbsp;used by HTML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should change the % sign to the HTML Entity representation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See here an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing;
  length text $ 1024;
  text='Some text %sugus some more';
  call symputx('mvar1',text);
  text='Some text %and some more';
  call symputx('mvar2',text);
  text='Some text &amp;amp;#37;and some more';
  call symputx('mvar3',text);
run;

%put %superq(mvar1);
%put %superq(mvar2);
%put %superq(mvar3);

ods html file="c:\temp\sometext.html";

ods text="&amp;lt;p class=""bold""&amp;gt;%superq(mvar1)&amp;lt;/p&amp;gt;";
ods text="&amp;lt;p class=""bold""&amp;gt;%superq(mvar2)&amp;lt;/p&amp;gt;";
ods text="&amp;lt;p class=""bold""&amp;gt;%superq(mvar3)&amp;lt;/p&amp;gt;";

proc print data=sashelp.class(obs=1);
run;

ods html close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can find a list of the HTML Entities here&amp;nbsp;&lt;A href="https://dev.w3.org/html5/html-author/charref" target="_blank"&gt;https://dev.w3.org/html5/html-author/charref&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 09:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329328#M17857</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-02-02T09:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: ODS TEXT with macro variable containing %-sign inside</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329394#M17858</link>
      <description>&lt;P&gt;Well thank you for the answer. That was indeed the problem in this case. However at least I get an warning on the log too that could not resolve macro %macroname if there is a % sign inside the ods text. So the next question is if my ods destination isn't html but something else how can I bypass that? Well that is more of a philosophical question since I got my issue solved.&lt;/P&gt;
&lt;P&gt;Do you happen to know if there is a function in SAS which automatically translates special characters into HTML entities? The problem is that the text can contain basically any special character and I definately wouldn't want to hard code the transformation in every case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Found the HTMLENCODE function, but unfortunately it does not encode all characters (especially % is missing).&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 12:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329394#M17858</guid>
      <dc:creator>BobHope</dc:creator>
      <dc:date>2017-02-02T12:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: ODS TEXT with macro variable containing %-sign inside</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329400#M17859</link>
      <description>&lt;P&gt;hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are the HTMLENCODE / HTMLDECODE functions, but they&amp;nbsp;will not encode the % sign, they will others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 12:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-with-macro-variable-containing-sign-inside/m-p/329400#M17859</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-02-02T12:38:32Z</dc:date>
    </item>
  </channel>
</rss>

