<?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: Aligning percentages in PROC REPORT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839427#M331914</link>
    <description>&lt;P&gt;You show us code for 5 variables, but your report seems to contain 12.&lt;/P&gt;
&lt;P&gt;Also, without knowing the data used to create the report, the code alone is not useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So please post a sample of your data in usabke form (dara step with datalines,&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;DO NOT SKIP THIS!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;), and your complete code, from PROC REPORT to RUN.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 16:37:35 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-10-19T16:37:35Z</dc:date>
    <item>
      <title>Aligning percentages in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839423#M331912</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have another question regarding aligning percentages in PROC Report. So currently my output is slightly off.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smackerz1988_0-1666195687270.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76322i74180B2CD41A8ECD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_0-1666195687270.png" alt="smackerz1988_0-1666195687270.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;how can I consistently align them so they are the same regardless of the number and spacing. This would be the ideal output based on the example provided&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smackerz1988_1-1666196077316.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76323i801D47D518F19D94/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_1-1666196077316.png" alt="smackerz1988_1-1666196077316.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is my code currently&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro output(col=,
              page=);
    
    proc report data = page missing style=VeraRTF style(report)=[width=100% ] &amp;amp;_reportopts.;

        column paramn aval cond1 paramn &amp;amp;col.;

         /* Non printed order variables */
      define paramn / order order=internal noprint;
      define aval / order order=internal noprint;
      
      

  /* Non printed variable used for indenting */
  define cond1 / noprint;

        define col1    /  id " " order order = internal     style(column)=[width=28% asis=on just=l]
                                                    style(header)=[width=28% asis=on just=l];
        
        %if &amp;amp;page. = 1  %then %do;
            define col2    / id " " order  order = internal style(column)=[width=3%  asis=on just=l ];
            define col3    / order order = internal style(column)=[width=11%   asis=on just=l leftmargin = 2.5%];
            define col4    / order order = internal style(column)=[width=11%  asis=on just=l leftmargin = 2.5%];
            define col5    / order order = internal style(column)=[width=11%  asis=on just=l leftmargin = 2.5%];
            define col6    / order order = internal style(column)=[width=11%  asis=on just=l leftmargin = 2.5%];
        %end;
        %if &amp;amp;page. = 2 %then %do;
            define col7    / page order order = internal style(column)=[width=11%  asis=on just=l leftmargin = 2.5%];
            define col8    / order order = internal style(column)=[width=10%  asis=on just=l leftmargin = 2.5%];
            define col9    / order order = internal style(column)=[width=8%  asis=on just=l leftmargin = 2.5%];
            define col10   / order order = internal style(column)=[width=8%  asis=on just=l leftmargin = 2.5%];
            define col11   / order order = internal style(column)=[width=8%  asis=on just=l leftmargin = 2.5%];
        %end;
        

         * Col1 indent *;
        compute col1;
           if cond1 eq 'Y' then call define(_col_, "style/merge", "style=[leftmargin=1.6%]");
         endcomp;

   *Skip line *;
  compute before paramn;
   line " ";
  endcomp;

    run;
%mend;

%output(col  = col1 col2 col3 col4 col5 col6,
        page = 1);

%output(col  = col1 col7 col8 col9 col10 col11,
        page = 2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 16:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839423#M331912</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-10-19T16:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Aligning percentages in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839427#M331914</link>
      <description>&lt;P&gt;You show us code for 5 variables, but your report seems to contain 12.&lt;/P&gt;
&lt;P&gt;Also, without knowing the data used to create the report, the code alone is not useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So please post a sample of your data in usabke form (dara step with datalines,&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;DO NOT SKIP THIS!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;), and your complete code, from PROC REPORT to RUN.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 16:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839427#M331914</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-19T16:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Aligning percentages in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839454#M331918</link>
      <description>&lt;P&gt;Personally I would say that your Count, or what ever the 2 represents is what is off.&lt;/P&gt;
&lt;P&gt;Show how you make those strings. I guess that you are concatenating a value of 2 with the percentage. I would say the part creating 2 (and all of those 0s which are also not aligned) should be using a different approach but without seeing exactly what you are doing it is hard to make a recommendation..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS You are not aligning percentages, you are aligning character values. Which will likely have problem if you ever display this result with anything other than a fixed width font like Courier or SAS Monospace.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 17:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839454#M331918</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-19T17:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Aligning percentages in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839456#M331919</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  **Construct character variable parts;
   if aval gt 0 then do;
      if denom le 0 or count le 0 then numpart = '0';
      else                             numpart = trim(left(put(count,8.)));

      if denom le 0 or count le 0  then pctpart = '';
      else                              pctpart = trim(left(put(round(count*100/denom, 0.1), pct1dp.)));
   end;

run;

**Find space required for each part ;
proc sql noprint;
   select max(max(lengthn(strip(numpart))),1), 
          max(max(lengthn(strip(pctpart))),1) into :numlength, :pctlength
   from all_counts;
quit;

** Produce formatted results;
data npct;
   length result $34;
   set all_counts;

   lengthr=length(numpart); 

   if lengthr = 1 then do;
   result = right(put(numpart, 3.)) || '  ' || right(put(pctpart, &amp;amp;pctlength..));
   end;

   if lengthr = 2 then do;
   result = right(put(numpart, 3.)) || ' ' || right(put(pctpart, &amp;amp;pctlength..));
   end;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is how I'm constructing it and the lengthr coding is me trying to adjust for the issue&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 17:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aligning-percentages-in-PROC-REPORT/m-p/839456#M331919</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-10-19T17:48:56Z</dc:date>
    </item>
  </channel>
</rss>

