<?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: Rounding error in PROC TABULATE or PROC FORMAT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878806#M347197</link>
    <description>&lt;P&gt;Thanks for your response. I am now running the below code. In the second line, "datalines" is not colored blue. Is it not recognized by SAS?&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="Cuneyt_0-1685647911853.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84622i44FC1342970E7752/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cuneyt_0-1685647911853.png" alt="Cuneyt_0-1685647911853.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;When I run this code, SAS does not read the data. I get the following error:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cuneyt_1-1685648104776.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84623i801E7A3C47C2DDB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cuneyt_1-1685648104776.png" alt="Cuneyt_1-1685648104776.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2023 19:35:29 GMT</pubDate>
    <dc:creator>Cuneyt</dc:creator>
    <dc:date>2023-06-01T19:35:29Z</dc:date>
    <item>
      <title>Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878740#M347188</link>
      <description>&lt;P&gt;I would like to build a table that shows counts and percentages. The below code displays the correct percentages with "009.9%", but not with "009%". How can I get the correct percentages displayed with no decimal places?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b @@;
datalines;
1	1	1	1	0	1	1	0	0	0	0	1
1	1	0	1	0	0	0	1	1	0	0	0
1	1	0	1	0	0	0	1	1	0	0	0;
run;
proc format;                           
   picture mypct (round) low-high='009%';   
run; 
proc tabulate data=have format=comma.;
	class a b;
	table a *(n='Number' pctn&amp;lt;a&amp;gt;='Col Pct'*f=mypct. ) all, b ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jun 2023 17:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878740#M347188</guid>
      <dc:creator>Cuneyt</dc:creator>
      <dc:date>2023-06-01T17:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878749#M347189</link>
      <description>&lt;P&gt;When I run your tabulate code with NO format for the Pctn using this code:&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=have format=comma.;
	class a b;
	table a *(n='Number' pctn&amp;lt;a&amp;gt;='Col Pct' ) all, b ;
run;
&lt;/PRE&gt;
&lt;P&gt;the result looks like:&lt;/P&gt;
&lt;DIV class="branch"&gt;&lt;A target="_blank" name="IDX4"&gt;&lt;/A&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" cellspacing="0" cellpadding="3"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" colspan="2" rowspan="2" scope="colgroup"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c m header" colspan="2" scope="colgroup"&gt;b&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c m header" scope="col"&gt;0&lt;/TH&gt;
&lt;TH class="c m header" scope="col"&gt;1&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;a&lt;/TH&gt;
&lt;TH class="l m rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD rowspan="2" class="r b data"&gt;5&lt;/TD&gt;
&lt;TD rowspan="2" class="r b data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" rowspan="2" scope="rowgroup"&gt;0&lt;/TH&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Number&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Col Pct&lt;/TH&gt;
&lt;TD class="r b data"&gt;63&lt;/TD&gt;
&lt;TD class="r b data"&gt;60&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" rowspan="2" scope="rowgroup"&gt;1&lt;/TH&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Number&lt;/TH&gt;
&lt;TD class="r b data"&gt;3&lt;/TD&gt;
&lt;TD class="r b data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Col Pct&lt;/TH&gt;
&lt;TD class="r b data"&gt;38&lt;/TD&gt;
&lt;TD class="r b data"&gt;40&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;All&lt;/TH&gt;
&lt;TH class="l m rowheader" scope="row"&gt;N&lt;/TH&gt;
&lt;TD class="r b data"&gt;8&lt;/TD&gt;
&lt;TD class="r b data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;With your format:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" cellspacing="0" cellpadding="3"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" colspan="2" rowspan="2" scope="colgroup"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c m header" colspan="2" scope="colgroup"&gt;b&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c m header" scope="col"&gt;0&lt;/TH&gt;
&lt;TH class="c m header" scope="col"&gt;1&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;a&lt;/TH&gt;
&lt;TH class="l m rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD rowspan="2" class="r b data"&gt;5&lt;/TD&gt;
&lt;TD rowspan="2" class="r b data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" rowspan="2" scope="rowgroup"&gt;0&lt;/TH&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Number&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Col Pct&lt;/TH&gt;
&lt;TD class="r b data"&gt;63%&lt;/TD&gt;
&lt;TD class="r b data"&gt;60%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" rowspan="2" scope="rowgroup"&gt;1&lt;/TH&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Number&lt;/TH&gt;
&lt;TD class="r b data"&gt;3&lt;/TD&gt;
&lt;TD class="r b data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Col Pct&lt;/TH&gt;
&lt;TD class="r b data"&gt;38%&lt;/TD&gt;
&lt;TD class="r b data"&gt;40%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;All&lt;/TH&gt;
&lt;TH class="l m rowheader" scope="row"&gt;N&lt;/TH&gt;
&lt;TD class="r b data"&gt;8&lt;/TD&gt;
&lt;TD class="r b data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;So, what do you want it to look like? I don't see any decimals. What would the "correct" percentages be?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, you should not have the semicolon ending the datalines on a line with data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42238"&gt;@Cuneyt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would like to build a table that shows counts and percentages. The below code displays the correct percentages with "009.9%", but not with "009%". How can I get the correct percentages displayed with no decimal places?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b @@;
datalines;
1	1	1	1	0	1	1	0	0	0	0	1
1	1	0	1	0	0	0	1	1	0	0	0
1	1	0	1	0	0	0	1	1	0	0	0;
run;
proc format;                           
   picture mypct (round) low-high='009%';   
run; 
proc tabulate data=have format=comma.;
	class a b;
	table a *(n='Number' pctn&amp;lt;a&amp;gt;='Col Pct'*f=mypct. ) all, b ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 18:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878749#M347189</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-01T18:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878756#M347190</link>
      <description>&lt;P&gt;Sorry for my unclear question. When I use "009.9%", the first column's percentages are 62.5% and 37.5%, which DO add up to 100%.&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" width="178px" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" colspan="2" rowspan="2" scope="colgroup" width="66.2px"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" colspan="2" scope="colgroup" width="111px"&gt;b&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col" width="53.9875px"&gt;0&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="57.0125px"&gt;1&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row" width="16.8625px"&gt;a&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD rowspan="2" width="53.9875px" class="r b data"&gt;5&lt;/TD&gt;
&lt;TD rowspan="2" width="57.0125px" class="r b data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="2" scope="rowgroup" width="16.8625px"&gt;0&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;Number&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;Col Pct&lt;/TH&gt;
&lt;TD width="53.9875px" class="r b data"&gt;62.5%&lt;/TD&gt;
&lt;TD width="57.0125px" class="r b data"&gt;60.0%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="2" scope="rowgroup" width="16.8625px"&gt;1&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;Number&lt;/TH&gt;
&lt;TD width="53.9875px" class="r b data"&gt;3&lt;/TD&gt;
&lt;TD width="57.0125px" class="r b data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;Col Pct&lt;/TH&gt;
&lt;TD width="53.9875px" class="r b data"&gt;37.5%&lt;/TD&gt;
&lt;TD width="57.0125px" class="r b data"&gt;40.0%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row" width="16.8625px"&gt;All&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;N&lt;/TH&gt;
&lt;TD width="53.9875px" class="r b data"&gt;8&lt;/TD&gt;
&lt;TD width="57.0125px" class="r b data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use "009%", the first column's percentages are 63% and 38%, which do NOT add up to 100%. How I can fix this problem?&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" colspan="2" rowspan="2" scope="colgroup"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" colspan="2" scope="colgroup"&gt;b&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col"&gt;0&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;1&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;a&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD rowspan="2" class="r b data"&gt;5&lt;/TD&gt;
&lt;TD rowspan="2" class="r b data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="2" scope="rowgroup"&gt;0&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Number&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Col Pct&lt;/TH&gt;
&lt;TD class="r b data"&gt;63%&lt;/TD&gt;
&lt;TD class="r b data"&gt;60%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="2" scope="rowgroup"&gt;1&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Number&lt;/TH&gt;
&lt;TD class="r b data"&gt;3&lt;/TD&gt;
&lt;TD class="r b data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Col Pct&lt;/TH&gt;
&lt;TD class="r b data"&gt;38%&lt;/TD&gt;
&lt;TD class="r b data"&gt;40%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;All&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;N&lt;/TH&gt;
&lt;TD class="r b data"&gt;8&lt;/TD&gt;
&lt;TD class="r b data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 01 Jun 2023 18:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878756#M347190</guid>
      <dc:creator>Cuneyt</dc:creator>
      <dc:date>2023-06-01T18:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878757#M347191</link>
      <description>&lt;P&gt;Note that you can also easily create a situation where the total is 99% instead of 100% when you have more than two categories.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what kind of FIX did you have in mind?&amp;nbsp; How would you decide which value to represent differently?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What most people do is just add a footnote.&amp;nbsp; Like this table I found on the internet.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.researchgate.net/figure/Note-All-percentages-may-not-total-100-due-to-rounding-ACE-and-Seat-Belt-Use_tbl1_310671376" target="_blank"&gt;https://www.researchgate.net/figure/Note-All-percentages-may-not-total-100-due-to-rounding-ACE-and-Seat-Belt-Use_tbl1_310671376&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 19:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878757#M347191</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-01T19:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878771#M347192</link>
      <description>&lt;P&gt;I presume your complaint is that rounding to whole percentages results in a set of column percentages summing to 101%&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your original percentages (37.5% and 62.5%) were both "rounded" upwards, to 38% and 63% respectively.&amp;nbsp; I don't see a way past that rounding behavior for cells in proc tabulate.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 18:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878771#M347192</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-06-01T18:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878780#M347193</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;The format you've created should do the trick!&amp;nbsp; &amp;nbsp;the issue(s) you are running into is that 1) the raw data appears tab-delimited; 2) you should not place a semi-colon on the same line as the raw data, but immediately after on a separate line; and 3) no RUN statement necessary when reading raw data.&amp;nbsp; &amp;nbsp;Note my change on the INFILE line.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="donricardo_0-1685645770279.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84603i8FE21D0A8118C1FB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="donricardo_0-1685645770279.png" alt="donricardo_0-1685645770279.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="donricardo_1-1685645817586.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84604iA220ED2C2F505E65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="donricardo_1-1685645817586.png" alt="donricardo_1-1685645817586.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 18:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878780#M347193</guid>
      <dc:creator>donricardo</dc:creator>
      <dc:date>2023-06-01T18:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878806#M347197</link>
      <description>&lt;P&gt;Thanks for your response. I am now running the below code. In the second line, "datalines" is not colored blue. Is it not recognized by SAS?&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="Cuneyt_0-1685647911853.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84622i44FC1342970E7752/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cuneyt_0-1685647911853.png" alt="Cuneyt_0-1685647911853.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;When I run this code, SAS does not read the data. I get the following error:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cuneyt_1-1685648104776.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84623i801E7A3C47C2DDB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cuneyt_1-1685648104776.png" alt="Cuneyt_1-1685648104776.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 19:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878806#M347197</guid>
      <dc:creator>Cuneyt</dc:creator>
      <dc:date>2023-06-01T19:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878807#M347198</link>
      <description>Thanks, Tom.</description>
      <pubDate>Thu, 01 Jun 2023 19:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878807#M347198</guid>
      <dc:creator>Cuneyt</dc:creator>
      <dc:date>2023-06-01T19:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878809#M347199</link>
      <description>Thank you. I think you are right.</description>
      <pubDate>Thu, 01 Jun 2023 19:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878809#M347199</guid>
      <dc:creator>Cuneyt</dc:creator>
      <dc:date>2023-06-01T19:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878811#M347200</link>
      <description>&lt;P&gt;Not actually a response to the question of what you think the result &lt;STRONG&gt;should&lt;/STRONG&gt; look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ANY result involving fixing the number of digits to display can have similar just shifted results. You can have a format that displays 5 decimal places and when you total the displayed range could end up with 99.99999 or 100.00001. It is the nature of real numbers.&lt;/P&gt;
&lt;P&gt;YOU have to tell us what you expect a displayed value to look like but be aware that it will be hard to write a set of generic rules that will cover every single case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42238"&gt;@Cuneyt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry for my unclear question. When I use "009.9%", the first column's percentages are 62.5% and 37.5%, which DO add up to 100%.&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" width="178px" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" colspan="2" rowspan="2" scope="colgroup" width="66.2px"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" colspan="2" scope="colgroup" width="111px"&gt;b&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col" width="53.9875px"&gt;0&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="57.0125px"&gt;1&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row" width="16.8625px"&gt;a&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD rowspan="2" width="53.9875px" class="r b data"&gt;5&lt;/TD&gt;
&lt;TD rowspan="2" width="57.0125px" class="r b data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="2" scope="rowgroup" width="16.8625px"&gt;0&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;Number&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;Col Pct&lt;/TH&gt;
&lt;TD width="53.9875px" class="r b data"&gt;62.5%&lt;/TD&gt;
&lt;TD width="57.0125px" class="r b data"&gt;60.0%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="2" scope="rowgroup" width="16.8625px"&gt;1&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;Number&lt;/TH&gt;
&lt;TD width="53.9875px" class="r b data"&gt;3&lt;/TD&gt;
&lt;TD width="57.0125px" class="r b data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;Col Pct&lt;/TH&gt;
&lt;TD width="53.9875px" class="r b data"&gt;37.5%&lt;/TD&gt;
&lt;TD width="57.0125px" class="r b data"&gt;40.0%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row" width="16.8625px"&gt;All&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row" width="49.3375px"&gt;N&lt;/TH&gt;
&lt;TD width="53.9875px" class="r b data"&gt;8&lt;/TD&gt;
&lt;TD width="57.0125px" class="r b data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use "009%", the first column's percentages are 63% and 38%, which do NOT add up to 100%. How I can fix this problem?&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" colspan="2" rowspan="2" scope="colgroup"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" colspan="2" scope="colgroup"&gt;b&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col"&gt;0&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;1&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;a&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD rowspan="2" class="r b data"&gt;5&lt;/TD&gt;
&lt;TD rowspan="2" class="r b data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="2" scope="rowgroup"&gt;0&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Number&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Col Pct&lt;/TH&gt;
&lt;TD class="r b data"&gt;63%&lt;/TD&gt;
&lt;TD class="r b data"&gt;60%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="2" scope="rowgroup"&gt;1&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Number&lt;/TH&gt;
&lt;TD class="r b data"&gt;3&lt;/TD&gt;
&lt;TD class="r b data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Col Pct&lt;/TH&gt;
&lt;TD class="r b data"&gt;38%&lt;/TD&gt;
&lt;TD class="r b data"&gt;40%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;All&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;N&lt;/TH&gt;
&lt;TD class="r b data"&gt;8&lt;/TD&gt;
&lt;TD class="r b data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 19:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878811#M347200</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-01T19:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878892#M347252</link>
      <description>&lt;P&gt;DO NOT PUT TABS IN YOUR IN-LINE DATA LINES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the normal old SAS Display Manger and submit the code SAS will convert the tabs into spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Actually don't but tabs anywhere in your SAS code, they just cause trouble).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use tab as the delimiter then store the data into a file and use an INFILE statement to point to the file instead of using DATALINES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 04:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/878892#M347252</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-02T04:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding error in PROC TABULATE or PROC FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/879012#M347282</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42238"&gt;@Cuneyt&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the special case of only &lt;EM&gt;two&lt;/EM&gt; categories (with percentages adding up to 100%) an extension of your MYPCT. format built around the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n02h2rvq30k869n164ccmcwvhqyk.htm" target="_blank" rel="noopener"&gt;ROUNDE function&lt;/A&gt; should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data roundepct;
retain fmtname 'roundepct';
length label $9;
do start=0.5 to 99.5;
  label=cats(rounde(start),'%');
  output;
end;
hlo='OF';
label='[mypct4.]';
output;
run;

proc format cntlin=roundepct;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use&amp;nbsp;&lt;FONT face="courier new,courier"&gt;f=roundepct.&lt;/FONT&gt; in the PROC TABULATE step.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 14:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-error-in-PROC-TABULATE-or-PROC-FORMAT/m-p/879012#M347282</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-06-02T14:26:55Z</dc:date>
    </item>
  </channel>
</rss>

