<?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: how to calculate with macro while writing ods in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700841#M214533</link>
    <description>&lt;P&gt;To use a data step function like that, you need to wrap it in %sysfunc, and for calculations, you need either %eval (integer) or %sysevalf (floating point).&lt;/P&gt;
&lt;P&gt;Since that would blow up the code and make it less readable, I prefer a data _null_ step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symputx('rate',put(&amp;amp;x./&amp;amp;total.,percent7.2));
run;
ods rtf text = "~S={outputwidth=100% just=c font=('Times New Roman',12pt)} { *In &amp;amp;total. patients of study, &amp;amp;rate. are not having data}"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Nov 2020 05:43:47 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-11-23T05:43:47Z</dc:date>
    <item>
      <title>how to calculate with macro while writing ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700836#M214530</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS programming, and trying to write the statement "In X patients of study, y% are not having data" in my ods statement, but the values are not getting calculated as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Requirement:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I've two macro variables and I'd like to write a string to ods, in that string add a percentage calculated from the two macro variables.&lt;/P&gt;&lt;P&gt;%let x = 20;&lt;/P&gt;&lt;P&gt;%total = 150;&lt;/P&gt;&lt;P&gt;ods rtf text = "~S={outputwidth=100% just=c font=('Times New Roman',12pt)} { *In &amp;amp;x patients of study. (round(&amp;amp;x./&amp;amp;total. * 100,.02)%) are not having data}";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Seems like round function only works in data step, but here it's not working.&lt;/P&gt;&lt;P&gt;How can I calculate the percentage on the fly and include in the ods text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 05:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700836#M214530</guid>
      <dc:creator>chandanar</dc:creator>
      <dc:date>2020-11-23T05:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate with macro while writing ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700839#M214532</link>
      <description>&lt;P&gt;It seems it's now time to learn how to use the &lt;FONT face="courier new,courier"&gt;%sysfunc&lt;/FONT&gt; function.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 05:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700839#M214532</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-11-23T05:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate with macro while writing ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700841#M214533</link>
      <description>&lt;P&gt;To use a data step function like that, you need to wrap it in %sysfunc, and for calculations, you need either %eval (integer) or %sysevalf (floating point).&lt;/P&gt;
&lt;P&gt;Since that would blow up the code and make it less readable, I prefer a data _null_ step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symputx('rate',put(&amp;amp;x./&amp;amp;total.,percent7.2));
run;
ods rtf text = "~S={outputwidth=100% just=c font=('Times New Roman',12pt)} { *In &amp;amp;total. patients of study, &amp;amp;rate. are not having data}"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 05:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700841#M214533</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-23T05:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate with macro while writing ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700852#M214538</link>
      <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, that worked!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 08:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-with-macro-while-writing-ods/m-p/700852#M214538</guid>
      <dc:creator>chandanar</dc:creator>
      <dc:date>2020-11-23T08:09:56Z</dc:date>
    </item>
  </channel>
</rss>

