<?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: several question for ods excel using proc report with line statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824416#M325590</link>
    <description>&lt;P&gt;you are right, and&amp;nbsp;I did spent lots of time on aligning them.&lt;/P&gt;&lt;P&gt;could you please share your solution, thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2022 16:49:34 GMT</pubDate>
    <dc:creator>JeffSAS</dc:creator>
    <dc:date>2022-07-20T16:49:34Z</dc:date>
    <item>
      <title>several question for ods excel using proc report with line statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824255#M325499</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;proc sql noprint;select sum(age),sum(height),sum(weight), sum(height)/sum(weight) format=percent8.2 into :s1,:s2,:s3,:ratio from sashelp.class; quit;
%put s1=&amp;amp;s1. s2=&amp;amp;s2. s3=&amp;amp;s3. ratio=&amp;amp;ratio.;

ods excel close;
 ods excel file="c:///class1.xlsx" options(sheet_name="tab1" autofilter='1-2');
    ods escapechar='^';
   ods text=" total age is  |     total hight is      |  total weight is   | % ratio ";
   ods text=  "   &amp;amp;s1.  |         &amp;amp;s2.    |     &amp;amp;s3.   |   &amp;amp;ratio. ";

proc report data=sashelp.class  nocenter;
  column name sex age height weight;
  define name -- weight/ display;
  define age  / analysis sum format=comma12. style(column)= [cellwidth=.5in];
  define height / analysis sum format=comma12. style(column)= [cellwidth=.8in];*newly added column;
  define weight / analysis sum format=comma12. style(column)= [cellwidth=.8in];*newly added column;
rbreak before / summarize style=[background=lightblue font_weight=bold];* CONTENTS='Total';
  compute before;
    call define(_row_,'style', "style=[tagattr='formula:=subtotal(9,indirect(concatenate(address(2,column()),"":"",address(row()-1,column()))))']"); *for all numeric columns sum;
  endcomp;
run;
title;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to generate an.excel file with text in the report using ods excel/proc report line statement, but there are several questions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. can each header align to the left side of each cell?&lt;/P&gt;&lt;P&gt;2. the '%' is omitted in the .xlsx report (i.e. % ratio in ods text statement, they should show up in row1 and row 2 in the report), how I can keep it in the report?&lt;/P&gt;&lt;P&gt;3. the total (in line 4 in the report) for each column are 0s, and how can they display the correct numbers(i.e. the total age should 253 instead of 0).&lt;/P&gt;&lt;P&gt;4. is there any way to control the ods test length or format, because if the test is longer, the test will be wrapped in multiple rows(i.e. row 1 and row 2, I need it stay in one row)&lt;/P&gt;&lt;P&gt;thanks!&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas.PNG" style="width: 445px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73511i15F560C6702F1DA7/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas.PNG" alt="sas.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 22:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824255#M325499</guid>
      <dc:creator>JeffSAS</dc:creator>
      <dc:date>2022-07-19T22:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: several question for ods excel using proc report with line statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824278#M325515</link>
      <description>&lt;P&gt;You could do this without macro-variables, if an additional column is acceptable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.class nocenter;
   column name sex age height weight Ratio;

   define age / analysis sum format=comma12. style(column)=[cellwidth=.5in];
   define height / analysis sum format=comma12. style(column)=[cellwidth=.8in];
   define weight / analysis sum format=comma12. style(column)=[cellwidth=.8in];
   define Ratio / computed format=percent8.2;
   
   compute ratio;
      ratio = height.sum / weight.sum;
   endcomp;

   rbreak before / summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jul 2022 04:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824278#M325515</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-07-20T04:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: several question for ods excel using proc report with line statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824330#M325538</link>
      <description>&lt;P&gt;I don't understand your fourth requirement .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;select sum(age),sum(height),sum(weight), sum(height)/sum(weight) format=percent8.2 
 into :s1,:s2,:s3,:ratio trimmed from sashelp.class; quit;
%put s1=&amp;amp;s1. s2=&amp;amp;s2. s3=&amp;amp;s3. ratio=&amp;amp;ratio.;

ods excel close;
 ods excel file="c:\temp\class1.xlsx" options(sheet_name="tab1" autofilter='1-2' flow='table');
    ods escapechar='^';
  ods text=" total age is   |     total hight is    |  total weight is  | %% ratio  ";
  ods text= "^_^_&amp;amp;s1.       |         &amp;amp;s2.      |     &amp;amp;s3.       |   &amp;amp;ratio.% ";
proc report data=sashelp.class nowd nocenter style(header)={just=l};
  column name sex age height weight;
  define name -- weight/ display;
  define age  / analysis sum format=comma12. style(column)= [cellwidth=.5in];
  define height / analysis sum format=comma12. style(column)= [cellwidth=.8in];*newly added column;
  define weight / analysis sum format=comma12. style(column)= [cellwidth=.8in];*newly added column;
rbreak before / summarize style=[background=lightblue font_weight=bold];* CONTENTS='Total';
run;
title;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1658319815722.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73520iEE2C4C474E075965/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1658319815722.png" alt="Ksharp_0-1658319815722.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824330#M325538</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-20T12:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: several question for ods excel using proc report with line statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824331#M325539</link>
      <description>&lt;P&gt;thanks!&lt;/P&gt;&lt;P&gt;I need the rows 1-2 information as well.&lt;/P&gt;&lt;P&gt;and the '% ratio' was changed to 'ratio' and the '62.32%' was changed to '62.32', and wonder if we can fix that.&lt;/P&gt;&lt;P&gt;also, can we control the row 1-2 layout, like start with spaces in both rows?&amp;nbsp;&lt;/P&gt;&lt;P&gt;can we adjust headers name &amp;amp; sex to align to the left?&lt;/P&gt;&lt;P&gt;I tried to use line statement, but it caused the wrapping issue.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824331#M325539</guid>
      <dc:creator>JeffSAS</dc:creator>
      <dc:date>2022-07-20T12:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: several question for ods excel using proc report with line statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824370#M325570</link>
      <description>&lt;P&gt;I strongly suggest that if you are going to place things like ratio calculation results into macro variables that you take the time to control the conversion by creating a string with known properties, i.e. Put with a format. The SAS routines for converting numbers to text that would be used otherwise can lead to some oddities when a value is rounded differently than you may expect for creating the macro variable(s). You can spend a LOT of time trying to run down odd boundary value issues where you get some unexpected results intermittently. Go ahead, ask how I know. &lt;span class="lia-unicode-emoji" title=":frowning_face:"&gt;☹️&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 14:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824370#M325570</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-20T14:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: several question for ods excel using proc report with line statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824416#M325590</link>
      <description>&lt;P&gt;you are right, and&amp;nbsp;I did spent lots of time on aligning them.&lt;/P&gt;&lt;P&gt;could you please share your solution, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 16:49:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824416#M325590</guid>
      <dc:creator>JeffSAS</dc:creator>
      <dc:date>2022-07-20T16:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: several question for ods excel using proc report with line statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824475#M325611</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/429811"&gt;@JeffSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;you are right, and&amp;nbsp;I did spent lots of time on aligning them.&lt;/P&gt;
&lt;P&gt;could you please share your solution, thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First thing is to remember that macro variables are &lt;STRONG&gt;always&lt;/STRONG&gt; text. So if create a text value an place that in to the macro variable then you get what you want if the purpose is display. This would have the % as part of the text value of the macro variable for the ratio.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
   select sum(age),sum(height),sum(weight),  
   put (sum(height)/sum(weight),percent8.2) into :s1,:s2,:s3,:ratio 
   from sashelp.class; 
quit;&lt;/PRE&gt;
&lt;P&gt;If you might need the macro variable for calculation you might consider rounding the value&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
   select sum(age),sum(height),sum(weight), 
   round(sum(height)/sum(weight), 0.0001)  into :s1,:s2,:s3,:ratio 
   from sashelp.class; 
quit;&lt;/PRE&gt;
&lt;P&gt;And apply the percent or other formats after calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would consider one of these approaches for any macro variable created that would contain decimal portions.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 19:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/several-question-for-ods-excel-using-proc-report-with-line/m-p/824475#M325611</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-20T19:54:36Z</dc:date>
    </item>
  </channel>
</rss>

