<?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: Need help creating macro string for ODS RTF TEXT statement in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67987#M7849</link>
    <description>Hi All&lt;BR /&gt;
&lt;BR /&gt;
This is a solution that I posted to the individuals a few days ago.&lt;BR /&gt;
&lt;BR /&gt;
%macro test(text=); &lt;BR /&gt;
  ods rtf body="test.rtf"; &lt;BR /&gt;
  ods rtf text = "{&amp;amp;text}";   &lt;BR /&gt;
  proc print data=sashelp.class; &lt;BR /&gt;
  run; &lt;BR /&gt;
  ods rtf close; &lt;BR /&gt;
%mend; &lt;BR /&gt;
&lt;BR /&gt;
%test(text={\pard \phmrg\posxc {\qc\fs36\b\cf2 What} {\super a Great} &amp;gt; Title \par}); &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
This paper will explain more details.&lt;BR /&gt;
&lt;A href="http://www.lexjansen.com/phuse/2007/po/po06.pdf" target="_blank"&gt;http://www.lexjansen.com/phuse/2007/po/po06.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards &lt;BR /&gt;
Duong</description>
    <pubDate>Thu, 15 Jan 2009 17:01:55 GMT</pubDate>
    <dc:creator>Duong</dc:creator>
    <dc:date>2009-01-15T17:01:55Z</dc:date>
    <item>
      <title>Need help creating macro string for ODS RTF TEXT statement</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67982#M7844</link>
      <description>I have the following SAS code which works on its own (no macro)&lt;BR /&gt;
&lt;BR /&gt;
ods results on;&lt;BR /&gt;
ods rtf&lt;BR /&gt;
	body="C:\test.rtf";&lt;BR /&gt;
	ods rtf text = '~R/RTF" \pard \phmrg\posxc \qc\fs36\b " What a Great Title ~R/RTF" \par "'	;&lt;BR /&gt;
	proc print data=sashelp.class;&lt;BR /&gt;
	run;&lt;BR /&gt;
ods rtf close;&lt;BR /&gt;
&lt;BR /&gt;
I would like to be able to parameterize the rtf string so that a user could control alignment, bolding, fontsize, etc.  In the macro I created, the string that gets created either causes an error like: &lt;BR /&gt;
&lt;BR /&gt;
MPRINT(INSERTTEXT):   ods rtf text = '~R/RTF" \pard \phmrg\posxc \qc\fs36\b " What a Great Title ~R/RTF" \par "';&lt;BR /&gt;
&lt;BR /&gt;
ERROR 22-322: Expecting a quoted string.&lt;BR /&gt;
ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
This is especially frustrating since the resolved macro variable is exactly what I manually entered in the ods rtf text statement above.  So what's the difference between executing it as SAS code and letting the macro processor resolve it into SAS and then having SAS executing it?  It's the same thing right? (clearly it's not &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Here's a simplified version of the macro:&lt;BR /&gt;
&lt;BR /&gt;
%macro insertText(text, justify, fontSize, bold);&lt;BR /&gt;
	ods escapechar="~";&lt;BR /&gt;
&lt;BR /&gt;
	%let startRtf = %str(%'~R/RTF%" \pard \phmrg\posxc );&lt;BR /&gt;
	%let fontConfig = %str(\q&amp;amp;justify.\fs&amp;amp;fontSize.\&amp;amp;bold %" );&lt;BR /&gt;
	%let endRtf = %str(~R/RTF%" \par %"%');&lt;BR /&gt;
	%let wholeString = %str(ods rtf text = &amp;amp;startRtf&amp;amp;fontConfig%str( &amp;amp;text )&amp;amp;endRtf;);&lt;BR /&gt;
	%str(&amp;amp;wholeString);&lt;BR /&gt;
%mend insertText;&lt;BR /&gt;
ods rtf&lt;BR /&gt;
	body="C:\test.rtf";&lt;BR /&gt;
	%insertText(What a Great Title, c, 36, b)&lt;BR /&gt;
	proc print data=sashelp.class;&lt;BR /&gt;
	run;&lt;BR /&gt;
ods rtf close;&lt;BR /&gt;
&lt;BR /&gt;
MPRINT(INSERTTEXT):   ods rtf text = '~R/RTF" \pard \phmrg\posxc \qc\fs36\b " What a Great Title ~R/RTF" \par "';&lt;BR /&gt;
&lt;BR /&gt;
ERROR 22-322: Expecting a quoted string.&lt;BR /&gt;
ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
I imagine that my problem lies somewhere in the macro quoting, but more importantly, I'd like to understand why the resolved macro string throws an error when executed in the ODS RTF while the "regular" SAS code does not.&lt;BR /&gt;
&lt;BR /&gt;
I should have mentioned at the top, I know there are easier ways to enter a title with formatting (~S={}, justify=left, etc.), but I need the user to be able to enter this anywhere in an RTF document, not just the title.&lt;BR /&gt;
&lt;BR /&gt;
TIA,&lt;BR /&gt;
Dave</description>
      <pubDate>Mon, 05 Jan 2009 22:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67982#M7844</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-05T22:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need help creating macro string for ODS RTF TEXT statement</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67983#M7845</link>
      <description>Dave, &lt;BR /&gt;
&lt;BR /&gt;
I have test this solution with the use of bquote avoiding the % troubling use for isolated ' and so on&lt;BR /&gt;
but i fall also upon the same error message&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
191  ods rtf text=%insertText(What a Great Title, c, 36, b)&lt;BR /&gt;
NOTE: Line generated by the macro variable "RTF".&lt;BR /&gt;
1    '~R/RTF"\pard \phmrg\posxc \qc\fs36\b " What a Great Title  ~R/RTF"\par "'&lt;BR /&gt;
     -&lt;BR /&gt;
     22&lt;BR /&gt;
       -&lt;BR /&gt;
       200&lt;BR /&gt;
MPRINT(INSERTTEXT):  '~R/RTF"\pard \phmrg\posxc \qc\fs36\b " What a Great Title ~R/RTF"\par&lt;BR /&gt;
"';&lt;BR /&gt;
ERROR 22-322: Expecting a quoted string.&lt;BR /&gt;
ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;
192      proc print data=sashelp.class;&lt;BR /&gt;
193      run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
With a unquote the quoted string is founded!&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods escapechar="~";&lt;BR /&gt;
options mprint;&lt;BR /&gt;
%macro insertText(text, justify, fontSize, bold);&lt;BR /&gt;
%let Rtf = %bquote('~R/RTF"\pard \phmrg\posxc \q&amp;amp;justify.\fs&amp;amp;fontSize.\&amp;amp;bold " &lt;BR /&gt;
%str( &amp;amp;text ) ~R/RTF"\par "');&lt;BR /&gt;
&lt;BR /&gt;
	%unquote(&amp;amp;Rtf.);&lt;BR /&gt;
%mend insertText;&lt;BR /&gt;
&lt;BR /&gt;
ods rtf&lt;BR /&gt;
	body="d:\temp\test.rtf";&lt;BR /&gt;
ods rtf text=%insertText(What a Great Title, c, 36, b)&lt;BR /&gt;
	proc print data=sashelp.class;&lt;BR /&gt;
	run;&lt;BR /&gt;
ods rtf close;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
But i have also a question now&lt;BR /&gt;
because with this variation i cann't explain the appearance of the ; in the title!&lt;BR /&gt;
Anybody ? Cynthia?&lt;BR /&gt;
Quote handling in macro is always delicate!&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods escapechar="~";&lt;BR /&gt;
options mprint;&lt;BR /&gt;
%macro insertT(text, justify, fontSize, bold);&lt;BR /&gt;
%let Rtf = %bquote('~R/RTF"\pard \phmrg\posxc \q&amp;amp;justify.\fs&amp;amp;fontSize.\&amp;amp;bold ");&lt;BR /&gt;
%let Rtf1=%bquote( %str( &amp;amp;text ) ~R/RTF"\par "');&lt;BR /&gt;
	%unquote(&amp;amp;Rtf.&amp;amp;Rtf1.);&lt;BR /&gt;
%mend insertT;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ods rtf&lt;BR /&gt;
	body="d:\temp\test.rtf";&lt;BR /&gt;
ods rtf text=%insertT(What a Great Title, c, 36, b)&lt;BR /&gt;
	proc print data=sashelp.class;&lt;BR /&gt;
	run;&lt;BR /&gt;
ods rtf close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 06 Jan 2009 09:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67983#M7845</guid>
      <dc:creator>Andre</dc:creator>
      <dc:date>2009-01-06T09:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help creating macro string for ODS RTF TEXT statement</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67984#M7846</link>
      <description>Try this, it seems to work.  Using an %unquote instead of %str removes all of the masking of special characters (altered by the original %str( )s) during execution, which I suspect was the original problem.&lt;BR /&gt;
&lt;BR /&gt;
If you want to write that line to the SAS log, I suppose you can put a %put in there as well...&lt;BR /&gt;
&lt;BR /&gt;
%macro insertText(text, justify, fontSize, bold);&lt;BR /&gt;
ods escapechar="~";&lt;BR /&gt;
&lt;BR /&gt;
%let startRtf = %str(%'~R/RTF%" \pard \phmrg\posxc );&lt;BR /&gt;
%let fontConfig = %str(\q&amp;amp;justify.\fs&amp;amp;fontSize.\&amp;amp;bold %" );&lt;BR /&gt;
%let endRtf = %str(~R/RTF%" \par %"%');&lt;BR /&gt;
%let wholeString = %str(ods rtf text = &amp;amp;startRtf&amp;amp;fontConfig%str( &amp;amp;text )&amp;amp;endRtf;);&lt;BR /&gt;
%unquote(&amp;amp;wholeString);&lt;BR /&gt;
%mend insertText;&lt;BR /&gt;
ods rtf&lt;BR /&gt;
body="C:\test.rtf";&lt;BR /&gt;
%insertText(What a Great Title, c, 36, b)&lt;BR /&gt;
proc print data=sashelp.class;&lt;BR /&gt;
run;&lt;BR /&gt;
ods rtf close;</description>
      <pubDate>Wed, 14 Jan 2009 18:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67984#M7846</guid>
      <dc:creator>PatrickG</dc:creator>
      <dc:date>2009-01-14T18:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need help creating macro string for ODS RTF TEXT statement</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67985#M7847</link>
      <description>Meant to add that when I use %unquote() I don't see the semicolon in the title that Andre mentioned.</description>
      <pubDate>Wed, 14 Jan 2009 20:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67985#M7847</guid>
      <dc:creator>PatrickG</dc:creator>
      <dc:date>2009-01-14T20:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need help creating macro string for ODS RTF TEXT statement</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67986#M7848</link>
      <description>Yes,&lt;BR /&gt;
&lt;BR /&gt;
I ommit to report here that there has been a long discussion about this on sas-l&lt;BR /&gt;
and that the answer of Ian Withlock was very deep upon&lt;BR /&gt;
the way why (despite the fact that %str is better) with %bquote it was working &lt;BR /&gt;
and specially why a ; was appearing.&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://groups.google.fr/group/comp.soft-sys.sas/browse_thread/thread/17a2da7078b7c0b9#" target="_blank"&gt;http://groups.google.fr/group/comp.soft-sys.sas/browse_thread/thread/17a2da7078b7c0b9#&lt;/A&gt;</description>
      <pubDate>Thu, 15 Jan 2009 10:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67986#M7848</guid>
      <dc:creator>Andre</dc:creator>
      <dc:date>2009-01-15T10:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need help creating macro string for ODS RTF TEXT statement</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67987#M7849</link>
      <description>Hi All&lt;BR /&gt;
&lt;BR /&gt;
This is a solution that I posted to the individuals a few days ago.&lt;BR /&gt;
&lt;BR /&gt;
%macro test(text=); &lt;BR /&gt;
  ods rtf body="test.rtf"; &lt;BR /&gt;
  ods rtf text = "{&amp;amp;text}";   &lt;BR /&gt;
  proc print data=sashelp.class; &lt;BR /&gt;
  run; &lt;BR /&gt;
  ods rtf close; &lt;BR /&gt;
%mend; &lt;BR /&gt;
&lt;BR /&gt;
%test(text={\pard \phmrg\posxc {\qc\fs36\b\cf2 What} {\super a Great} &amp;gt; Title \par}); &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
This paper will explain more details.&lt;BR /&gt;
&lt;A href="http://www.lexjansen.com/phuse/2007/po/po06.pdf" target="_blank"&gt;http://www.lexjansen.com/phuse/2007/po/po06.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards &lt;BR /&gt;
Duong</description>
      <pubDate>Thu, 15 Jan 2009 17:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-creating-macro-string-for-ODS-RTF-TEXT-statement/m-p/67987#M7849</guid>
      <dc:creator>Duong</dc:creator>
      <dc:date>2009-01-15T17:01:55Z</dc:date>
    </item>
  </channel>
</rss>

