<?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 Proc TABULATE : FREQ option ignores decimals in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501936#M588</link>
    <description>&lt;P&gt;I'm trying to go from a simple two-way frequency table to a proc tabulate. However my weight value uses decimals (1.0677549165).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine with proc freq :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data region;
   infile datalines ;
   input flag:$1. year:$4. region:$8.;
   Correction = 79867/74799;
 datalines;
 Y 2018 Region01 
 Y 2017 Region02 
 N 2017 Region01 
 Y 2017 Region01 
 N 2018 Region02 
 Y 2017 Region01 
 Y 2017 Region01
 Y 2017 Region01 
 N 2018 Region01 
 Y 2018 Region01
 Y 2018 Region02 
 N 2018 Region02 
 Y 2017 Region01 
 N 2017 Region02
 Y 2017 Region01 
 N 2018 Region01 
 Y 2018 Region02 
 N 2017 Region01 
 Y 2017 Region01 
 Y 2018 Region01 
 N 2017 Region01
 N 2018 Region01
 N 2017 Region01
 N 2018 Region02
 N 2017 Region02
 N 2018 Region02
 Y 2018 Region02
 Y 2017 Region01
 Y 2018 Region01
 Y 2018 Region01
 ;;;;

 * Flag by region, flag by year;
proc freq data=region;

	table flag * region / nocum norow nopercent;
	table flag * year / nocum norow nopercent;

	weight Correction;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way I get two tables, one per region and one per year with the weight properly taken into account :&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="prob1.png" style="width: 430px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23811iCC5B322466A0F16A/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob1.png" alt="prob1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I would like to have a single table crossing both region and year. I would do this with proc tabulate :&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 tabulate data=region;
	
	class flag year region;

	table year * flag, region * (N pctn&amp;lt;flag all&amp;gt;) all;

	freq Correction;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The result is not weighted, because the FREQ option removes the decimals of Correction internally, in this case using the value of 1 :&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="prob2.png" style="width: 274px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23812iFD9387B0846720E5/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob2.png" alt="prob2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how I should proceed? Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Oct 2018 15:10:57 GMT</pubDate>
    <dc:creator>Franck1048</dc:creator>
    <dc:date>2018-10-05T15:10:57Z</dc:date>
    <item>
      <title>Proc TABULATE : FREQ option ignores decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501936#M588</link>
      <description>&lt;P&gt;I'm trying to go from a simple two-way frequency table to a proc tabulate. However my weight value uses decimals (1.0677549165).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine with proc freq :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data region;
   infile datalines ;
   input flag:$1. year:$4. region:$8.;
   Correction = 79867/74799;
 datalines;
 Y 2018 Region01 
 Y 2017 Region02 
 N 2017 Region01 
 Y 2017 Region01 
 N 2018 Region02 
 Y 2017 Region01 
 Y 2017 Region01
 Y 2017 Region01 
 N 2018 Region01 
 Y 2018 Region01
 Y 2018 Region02 
 N 2018 Region02 
 Y 2017 Region01 
 N 2017 Region02
 Y 2017 Region01 
 N 2018 Region01 
 Y 2018 Region02 
 N 2017 Region01 
 Y 2017 Region01 
 Y 2018 Region01 
 N 2017 Region01
 N 2018 Region01
 N 2017 Region01
 N 2018 Region02
 N 2017 Region02
 N 2018 Region02
 Y 2018 Region02
 Y 2017 Region01
 Y 2018 Region01
 Y 2018 Region01
 ;;;;

 * Flag by region, flag by year;
proc freq data=region;

	table flag * region / nocum norow nopercent;
	table flag * year / nocum norow nopercent;

	weight Correction;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way I get two tables, one per region and one per year with the weight properly taken into account :&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="prob1.png" style="width: 430px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23811iCC5B322466A0F16A/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob1.png" alt="prob1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I would like to have a single table crossing both region and year. I would do this with proc tabulate :&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 tabulate data=region;
	
	class flag year region;

	table year * flag, region * (N pctn&amp;lt;flag all&amp;gt;) all;

	freq Correction;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The result is not weighted, because the FREQ option removes the decimals of Correction internally, in this case using the value of 1 :&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="prob2.png" style="width: 274px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23812iFD9387B0846720E5/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob2.png" alt="prob2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how I should proceed? Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 15:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501936#M588</guid>
      <dc:creator>Franck1048</dc:creator>
      <dc:date>2018-10-05T15:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc TABULATE : FREQ option ignores decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501943#M589</link>
      <description>&lt;P&gt;Weights apply to variables in PROC TABULATE and you have no analysis variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you can add a 1 to each record and then do a SUM of that variable with the weights to get the values you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do think you need to be using WEIGHT again though, not PROC FREQ.&lt;/P&gt;
&lt;P&gt;See the changes in your code below, highlighted in purple. I did the counts, you can do the percentages :).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data region;
   infile datalines ;
   input flag:$1. year:$4. region:$8.;
   Correction = 79867/74799;
&lt;FONT size="5"&gt;&lt;STRONG&gt;&lt;FONT color="#800080"&gt;   Indicator=1;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;
 datalines;
 Y 2018 Region01 
 Y 2017 Region02 
 N 2017 Region01 
 Y 2017 Region01 
 N 2018 Region02 
 Y 2017 Region01 
 Y 2017 Region01
 Y 2017 Region01 
 N 2018 Region01 
 Y 2018 Region01
 Y 2018 Region02 
 N 2018 Region02 
 Y 2017 Region01 
 N 2017 Region02
 Y 2017 Region01 
 N 2018 Region01 
 Y 2018 Region02 
 N 2017 Region01 
 Y 2017 Region01 
 Y 2018 Region01 
 N 2017 Region01
 N 2018 Region01
 N 2017 Region01
 N 2018 Region02
 N 2017 Region02
 N 2018 Region02
 Y 2018 Region02
 Y 2017 Region01
 Y 2018 Region01
 Y 2018 Region01
 ;;;;

 * Flag by region, flag by year;
proc freq data=region;

	&lt;FONT size="4" color="#800080"&gt;&lt;STRONG&gt;table flag * region *year / list nocum norow nopercent;&lt;/STRONG&gt;&lt;/FONT&gt;

	weight Correction;

run;

proc tabulate data=region;
	
	class flag year region;
 &lt;FONT size="4" color="#800080"&gt;&lt;STRONG&gt;   var indicator;&lt;/STRONG&gt;&lt;/FONT&gt;
	table year * flag, region * (&lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#800080"&gt;indicator*Sum*f=8.2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt; pctn&amp;lt;flag all&amp;gt;) all;

	&lt;FONT size="5" color="#800080"&gt;&lt;STRONG&gt;weight Correction;&lt;/STRONG&gt;&lt;/FONT&gt;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/231511"&gt;@Franck1048&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to go from a simple two-way frequency table to a proc tabulate. However my weight value uses decimals (1.0677549165).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works fine with proc freq :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data region;
   infile datalines ;
   input flag:$1. year:$4. region:$8.;
   Correction = 79867/74799;
 datalines;
 Y 2018 Region01 
 Y 2017 Region02 
 N 2017 Region01 
 Y 2017 Region01 
 N 2018 Region02 
 Y 2017 Region01 
 Y 2017 Region01
 Y 2017 Region01 
 N 2018 Region01 
 Y 2018 Region01
 Y 2018 Region02 
 N 2018 Region02 
 Y 2017 Region01 
 N 2017 Region02
 Y 2017 Region01 
 N 2018 Region01 
 Y 2018 Region02 
 N 2017 Region01 
 Y 2017 Region01 
 Y 2018 Region01 
 N 2017 Region01
 N 2018 Region01
 N 2017 Region01
 N 2018 Region02
 N 2017 Region02
 N 2018 Region02
 Y 2018 Region02
 Y 2017 Region01
 Y 2018 Region01
 Y 2018 Region01
 ;;;;

 * Flag by region, flag by year;
proc freq data=region;

	table flag * region / nocum norow nopercent;
	table flag * year / nocum norow nopercent;

	weight Correction;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This way I get two tables, one per region and one per year with the weight properly taken into account :&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="prob1.png" style="width: 430px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23811iCC5B322466A0F16A/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob1.png" alt="prob1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I would like to have a single table crossing both region and year. I would do this with proc tabulate :&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 tabulate data=region;
	
	class flag year region;

	table year * flag, region * (N pctn&amp;lt;flag all&amp;gt;) all;

	freq Correction;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The result is not weighted, because the FREQ option removes the decimals of Correction internally, in this case using the value of 1 :&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="prob2.png" style="width: 274px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23812iFD9387B0846720E5/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob2.png" alt="prob2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea how I should proceed? Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 15:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501943#M589</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-05T15:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc TABULATE : FREQ option ignores decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501950#M590</link>
      <description>&lt;P&gt;It works with this method, but we don't need the weight statement here, otherwise it applies the weight "twice". So the solution would be :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=region;
	
	class flag year region;
        var Correction;

	table year * flag, region * (Correction*Sum*f=8.2 pctn&amp;lt;flag all&amp;gt;) all;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="prob3.png" style="width: 379px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23814i471A368B69B0F01D/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob3.png" alt="prob3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only problem with this table is the Total column, which displays the N. Any idea how to put the total of the sums instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 15:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501950#M590</guid>
      <dc:creator>Franck1048</dc:creator>
      <dc:date>2018-10-05T15:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc TABULATE : FREQ option ignores decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501956#M591</link>
      <description>&lt;P&gt;Modify the ALL to include the SUM rather than N. If no statistic is specified then you get N by default.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 15:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501956#M591</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-05T15:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc TABULATE : FREQ option ignores decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501964#M593</link>
      <description>&lt;P&gt;Ok&amp;nbsp;it worked with this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=region;
	
	class flag year region;
    var Correction;

	table year * flag, region  * (Correction*Sum*f=8.2 pctn&amp;lt;flag all&amp;gt;) all * (Correction*Sum*f=8.2 pctn&amp;lt;flag all&amp;gt;) ;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="prob4.png" style="width: 467px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23815i0647863BCD280D56/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob4.png" alt="prob4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That exactly the result I want. Thank you Reeza!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 15:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-TABULATE-FREQ-option-ignores-decimals/m-p/501964#M593</guid>
      <dc:creator>Franck1048</dc:creator>
      <dc:date>2018-10-05T15:56:08Z</dc:date>
    </item>
  </channel>
</rss>

