<?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 how to apply decimals alignment in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809423#M319207</link>
    <description>&lt;P&gt;data rawdata ;&lt;BR /&gt;input var1 total ;&lt;BR /&gt;/*calculating percentages*/&lt;BR /&gt;percentage=put(var1,5.)||'('||put((var1*100)/total,5.1)||')';&lt;BR /&gt;cards ;&lt;BR /&gt;23 169&lt;BR /&gt;33 169&lt;BR /&gt;23.5 169&lt;BR /&gt;2 30&lt;BR /&gt;12 43&lt;BR /&gt;12.342&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am calculating percentages and need to set correct alignement like&lt;BR /&gt;while generating report part output alignment should be like:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Percentages&lt;BR /&gt;&amp;nbsp; 23 (&amp;nbsp; 50.2&amp;nbsp; &amp;nbsp;%)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; 2 (&amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; %)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;324 (&amp;nbsp; 99.23 %)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 23 Apr 2022 06:57:58 GMT</pubDate>
    <dc:creator>thanikondharish</dc:creator>
    <dc:date>2022-04-23T06:57:58Z</dc:date>
    <item>
      <title>how to apply decimals alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809423#M319207</link>
      <description>&lt;P&gt;data rawdata ;&lt;BR /&gt;input var1 total ;&lt;BR /&gt;/*calculating percentages*/&lt;BR /&gt;percentage=put(var1,5.)||'('||put((var1*100)/total,5.1)||')';&lt;BR /&gt;cards ;&lt;BR /&gt;23 169&lt;BR /&gt;33 169&lt;BR /&gt;23.5 169&lt;BR /&gt;2 30&lt;BR /&gt;12 43&lt;BR /&gt;12.342&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am calculating percentages and need to set correct alignement like&lt;BR /&gt;while generating report part output alignment should be like:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Percentages&lt;BR /&gt;&amp;nbsp; 23 (&amp;nbsp; 50.2&amp;nbsp; &amp;nbsp;%)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; 2 (&amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; %)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;324 (&amp;nbsp; 99.23 %)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 06:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809423#M319207</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2022-04-23T06:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply decimals alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809424#M319208</link>
      <description>&lt;P&gt;Your "desired" output is actually not aligned. If you look at it in a fixed-length typeset it looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  23 (  50.2   %)
    2 (    3      %) 
324 (  99.23 %)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The blanks are a lot shorter in the Arial font you are using, which is what makes your "desired" output look "aligned" when presented on the web page in that font.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you, on the other hand, take the output from your program, and show it in a non-proportional font, it looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    23( 13.6)        
    33( 19.5)        
    24( 13.9)        
     2(  6.7)        
    12( 97.6)  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;- which is aligned OK, you just need to add some blanks and a percentage sign to make it look allright.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So perhaps you could overcome the problem by presenting the report in a font like Courier.&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>Sat, 23 Apr 2022 07:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809424#M319208</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-04-23T07:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply decimals alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809425#M319209</link>
      <description>We don't know how many decimals will come</description>
      <pubDate>Sat, 23 Apr 2022 07:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809425#M319209</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2022-04-23T07:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply decimals alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809426#M319210</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;We don't know how many decimals will come&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unless the numbers are divisible, the percentages will have about 15 significant decimals. if one number is 1 and the other 3, the floating-point number will contain this: "&lt;SPAN&gt;33.3333333333333". You will just have to make a decision about how many of those decimals you want to present, by changing the format to e.g. 6.3, or perhaps 16.13, if you really want all decimals there.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may look "bad" to you to have the number 3 represented as " 3.000", but is that really a problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case you could replace trailing zeroes (and decimal signs) with blanks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rawdata ;
input var1 total ;
/*calculating percentages*/
percentage=' '||put(var1,3.)||' ( '||put((var1*100)/total,5.2)||' %)';
prxid=prxparse('/\.?0+ /');
start=1;
len=0;
pos=0;
call prxnext(prxid,start,-1,percentage,pos,len);
if pos then 
  substr(percentage,pos,len)='';
put percentage $20.;
drop start prxid pos len;
cards ;
23 169
33 169
23.5 169
2 20
1 200
12.043 12.342
;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The regular expression tries to find one or zero decimal points (\.?), followed by one or more zeroes, and finally a blank. If the search is successful, the string found is blanked out.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 08:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809426#M319210</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-04-23T08:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply decimals alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809432#M319216</link>
      <description>&lt;P&gt;Using " just=dec" style .If you are using RTF destination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data rawdata ;
input var1 total ;
/*calculating percentages*/
percentage=put(var1,5.)||'('||put((var1*100)/total,5.1)||')';
cards ;
23 169
33 169
23.5 169
2 30
12 43
12.342
;
run;

ods rtf file='c:\temp\temp.rtf' style=journal;
proc report data=rawdata nowd;
define percentage /display style(column)={just=dec};
run;
ods rtf close;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Apr 2022 10:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-decimals-alignment/m-p/809432#M319216</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-04-23T10:41:12Z</dc:date>
    </item>
  </channel>
</rss>

