<?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 to apply multiple formats based on variable values in PROC REPORT, ODS TAGSETS in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431607#M20267</link>
    <description>Hi, your IF statement is testing X, it should be testing TYPE. Also, COMPUTED is the WRONG usage for TOTALS. Unless I misunderstand your data, it looks like your 2 variables are TYPE and TOTALS. Therefore, TOTALS is not new. You only use COMPUTED usage for a completely NEW variable. You can have a COMPUTE block on an existing variable. Please see page 9-10 of this paper &lt;A href="http://support.sas.com/resources/papers/proceedings16/SAS5762-2016.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings16/SAS5762-2016.pdf&lt;/A&gt; for a directly relevant example.&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
    <pubDate>Sun, 28 Jan 2018 13:46:10 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2018-01-28T13:46:10Z</dc:date>
    <item>
      <title>Need help to apply multiple formats based on variable values in PROC REPORT, ODS TAGSETS</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431575#M20266</link>
      <description>&lt;P&gt;Hi, I have an issue while applying multiple formats based on the variable values. I saw previous posts, but it was not helpful for me. Mistake might be from my end while applying proper formats. Please help me how to resolve this issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INPUT DATA:&lt;/P&gt;
&lt;P&gt;============&lt;/P&gt;
&lt;P&gt;TYPE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;TOTALS&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;39442499 &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt; 828727452.170335&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;519125592.249982&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt; 1491576104.14236&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;31241133938.0128&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;&amp;nbsp;2026005&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;2949321.99999995&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Lucida Console" size="3"&gt;REQUIRED OUTPUT:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Lucida Console" size="3"&gt;================&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;TYPE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;TOTALS&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;39,442,499 &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt; $8,28,727,452.17&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt; 519,125,592.25&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt; $1,491,576,104.14&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;$&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;31,241,133,938.01&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;&amp;nbsp;2,026,005&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;2,949,322&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the code as below but I am getting missing values under totals variable in excel sheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods tagsets.excelxp file='C:\Test\test.xls' style=sasweb;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;proc report data=sum nowd;&lt;/P&gt;
&lt;P&gt;Column TYPE TOTALS;&lt;/P&gt;
&lt;P&gt;define TYPE/ display style(column)={just=l};&lt;/P&gt;
&lt;P&gt;define TOTALS/computed style(column)={just=l};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;compute TOTALS;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;if x='B' then do;&lt;/P&gt;
&lt;P&gt;*call define(_col_,'format','dollar19.2');&lt;/P&gt;
&lt;P&gt;call define(_col_,'style','style={tagattr="Format:$#,##0.00"}');&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;else do;&lt;/P&gt;
&lt;P&gt;*call define(_col_,'format','comma12.');&lt;/P&gt;
&lt;P&gt;call define(_col_,'style','style={tagattr="Format:#,###"}');&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;endcomp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;ods _all_ close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PLEASE HELP ME ON THIS. THANKS IN ADVANCE.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2018 09:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431575#M20266</guid>
      <dc:creator>Banu</dc:creator>
      <dc:date>2018-01-28T09:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to apply multiple formats based on variable values in PROC REPORT, ODS TAGSETS</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431607#M20267</link>
      <description>Hi, your IF statement is testing X, it should be testing TYPE. Also, COMPUTED is the WRONG usage for TOTALS. Unless I misunderstand your data, it looks like your 2 variables are TYPE and TOTALS. Therefore, TOTALS is not new. You only use COMPUTED usage for a completely NEW variable. You can have a COMPUTE block on an existing variable. Please see page 9-10 of this paper &lt;A href="http://support.sas.com/resources/papers/proceedings16/SAS5762-2016.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings16/SAS5762-2016.pdf&lt;/A&gt; for a directly relevant example.&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Sun, 28 Jan 2018 13:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431607#M20267</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-01-28T13:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to apply multiple formats based on variable values in PROC REPORT, ODS TAGSETS</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431623#M20268</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;noted you should get a note in the LOG about trying to COMPUTE a variable with the same name as a variable on the input dataset.&lt;/P&gt;
&lt;PRE&gt;NOTE: The computed variable TOTALS is also a data set variable.
NOTE: The output might not be as expected.&lt;/PRE&gt;
&lt;P&gt;Making that change and referencing the TYPE variable your code should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input TYPE $ TOTALS ;
cards;
A 39442499
B 828727452.170335
B 519125592.249982
B 1491576104.14236
B 31241133938.0128
C 2026005
C 2949321.99999995
;

%let path=%sysfunc(pathname(work));
ods excel file="&amp;amp;path/test.xlsx";

proc report data=have nowd;
  column TYPE TOTALS;
  define TYPE/ display style(column)={just=l} width=4;
  define TOTALS/ display style(column)={just=l} width=19;
  compute TOTALS;
    if type='B' then do;
       call define(_col_,'format','dollar19.2');
       call define(_col_,'style','style={tagattr="Format:$#,##0.00"}');
    end;
    else do;
       call define(_col_,'format','comma12.');
       call define(_col_,'style','style={tagattr="Format:#,###"}');
    end;
  endcomp;
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;  TYPE               TOTALS
  A              39,442,499
  B         $828,727,452.17
  B         $519,125,592.25
  B       $1,491,576,104.14
  B      $31,241,133,938.01
  C               2,026,005
  C               2,949,322&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 208px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18161i3C18CFB350911546/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2018 19:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431623#M20268</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-28T19:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to apply multiple formats based on variable values in PROC REPORT, ODS TAGSETS</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431724#M20269</link>
      <description>Had few mistakes in my code and then corrected. Now it's working as expected. Thanks for your help.</description>
      <pubDate>Mon, 29 Jan 2018 10:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431724#M20269</guid>
      <dc:creator>Banu</dc:creator>
      <dc:date>2018-01-29T10:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to apply multiple formats based on variable values in PROC REPORT, ODS TAGSETS</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431726#M20270</link>
      <description>Cynthia, thank you so much for your suggestion. Attached doc is really helpful for me. Thank you.</description>
      <pubDate>Mon, 29 Jan 2018 10:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-apply-multiple-formats-based-on-variable-values-in/m-p/431726#M20270</guid>
      <dc:creator>Banu</dc:creator>
      <dc:date>2018-01-29T10:31:48Z</dc:date>
    </item>
  </channel>
</rss>

