<?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: conditional ods rtf text= in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691704#M210570</link>
    <description>&lt;P&gt;Intended to mark this one as the solution.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Oct 2020 23:16:57 GMT</pubDate>
    <dc:creator>cminard</dc:creator>
    <dc:date>2020-10-14T23:16:57Z</dc:date>
    <item>
      <title>conditional ods rtf text=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691664#M210547</link>
      <description>&lt;P&gt;Why doesn't this work?&lt;/P&gt;
&lt;P&gt;/*******************/&lt;/P&gt;
&lt;P&gt;data temp;&lt;BR /&gt;do id = 1 to 10;&lt;BR /&gt;x=ranuni(134);&lt;BR /&gt;y=ranuni(135);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;ods rtf file="&amp;lt;your directory&amp;gt;\test.rtf";&lt;BR /&gt;%macro m1 ();&lt;BR /&gt;%let mytitle=This is my title;&lt;BR /&gt;%let xvalue=;&lt;BR /&gt;data _null_;&lt;BR /&gt;set temp;&lt;BR /&gt;call symputx ('xvalue',x);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%let yvalue=999;&lt;BR /&gt;%if (&amp;amp;yvalue ne ) %then ods rtf text="Xvalue is %sysfunc(round(&amp;amp;xvalue,.01)).";&lt;BR /&gt;title "&amp;amp;mytitle";&lt;BR /&gt;proc sgplot data=temp;&lt;BR /&gt;scatter x=x y=y;&lt;BR /&gt;run;&lt;BR /&gt;title ;&lt;BR /&gt;%mend m1;&lt;BR /&gt;%m1;&lt;/P&gt;
&lt;P&gt;ods rtf close;&lt;/P&gt;
&lt;P&gt;/*********************/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I execute this code, I get the following error message:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cminard_1-1602707296528.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50674iAB600B94FB175D61/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cminard_1-1602707296528.png" alt="cminard_1-1602707296528.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 20:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691664#M210547</guid>
      <dc:creator>cminard</dc:creator>
      <dc:date>2020-10-14T20:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: conditional ods rtf text=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691669#M210551</link>
      <description>&lt;P&gt;Use a "DO; END" block on that if statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
do id = 1 to 10;
x=ranuni(134);
y=ranuni(135);
output;
end;
run;

ods rtf file="&amp;lt;your directory&amp;gt;\test.rtf";
%macro m1 ();
%let mytitle=This is my title;
%let xvalue=;
data _null_;
set temp;
call symputx ('xvalue',x);
run;

%let yvalue=999;
%if (&amp;amp;yvalue ne ) %then %do;
ods rtf text="Xvalue is %sysfunc(round(&amp;amp;xvalue,.01)).";
%end;
title "&amp;amp;mytitle";
proc sgplot data=temp;
scatter x=x y=y;
run;
title ;
%mend m1;
%m1;

ods rtf close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Oct 2020 20:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691669#M210551</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-10-14T20:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: conditional ods rtf text=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691671#M210553</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27112"&gt;@cminard&lt;/a&gt;&amp;nbsp; You are missing a semi colon to end the ODS RTF for the reason the semi colon present acts as step boundary rather for the %IF macro statement. You would need another semi colon, however the inner semi colon would have to be quoted aka masked to be treated as text using %STR funciton. So-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%if (&amp;amp;yvalue ne ) %then ods rtf text="Xvalue is %sysfunc(round(&amp;amp;xvalue,.01))."%str(;) ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Oct 2020 20:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691671#M210553</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-14T20:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: conditional ods rtf text=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691678#M210556</link>
      <description>&lt;P&gt;I would recommend moving all macro definitions outside of an ODS destination block (ODS destination/ ods destination close ). Partially it makes code easier to follow but may also address your spefic issue. Additionally to test just the output part you don't end up recompiling the macro multiple times (efficiency) and may be easier test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dummy code to illustrate what I mean.&lt;/P&gt;
&lt;PRE&gt;%macro m1();
&amp;lt;code in macro&amp;gt;
%mend m1;

ods rtf file ="path\file.rtf";

%m1;

ods rtf close;
&lt;/PRE&gt;
&lt;P&gt;Debug macro behavior by setting OPTIONS MPRINT; before execution. The log will usually have more details of what the macro compiler actually generated.&lt;/P&gt;
&lt;P&gt;Use Options NOMPRINT; to turn of the details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 21:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691678#M210556</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-14T21:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: conditional ods rtf text=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691699#M210566</link>
      <description>&lt;P&gt;The macro code is in red:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#FF0000"&gt;%if (&amp;amp;yvalue ne ) %then&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;ods rtf text="Xvalue is %sysfunc(round(&amp;amp;xvalue,.01))."&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;As you can see you haven't closed the ODS statement.&lt;/P&gt;
&lt;P&gt;You can add a &lt;FONT face="courier new,courier"&gt;%do&lt;/FONT&gt; block as shown, or another proper way would be:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#FF0000"&gt;%if (&amp;amp;yvalue ne ) %then&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;ods rtf text="Xvalue is %sysfunc(round(&amp;amp;xvalue,.01))."%str(;)&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;or just as good (and you'll get a semicolon even if the test fails):&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#FF0000"&gt;%if (&amp;amp;yvalue ne ) %then&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;ods rtf text="Xvalue is %sysfunc(round(&amp;amp;xvalue,.01)).&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;;&amp;nbsp; &lt;FONT color="#000000"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 22:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691699#M210566</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-10-14T22:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: conditional ods rtf text=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691701#M210568</link>
      <description>&lt;P&gt;Thank you all. Yes, I am missing a semi-colon to close that %if statement. Thanks for all other suggestions as well.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 23:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691701#M210568</guid>
      <dc:creator>cminard</dc:creator>
      <dc:date>2020-10-14T23:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: conditional ods rtf text=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691704#M210570</link>
      <description>&lt;P&gt;Intended to mark this one as the solution.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 23:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691704#M210570</guid>
      <dc:creator>cminard</dc:creator>
      <dc:date>2020-10-14T23:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: conditional ods rtf text=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691705#M210571</link>
      <description>&lt;P&gt;You can change&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 23:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-ods-rtf-text/m-p/691705#M210571</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-10-14T23:50:00Z</dc:date>
    </item>
  </channel>
</rss>

