<?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: Weight Categorical Variables in Proc Tabulate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392868#M94580</link>
    <description>Thank you for your help! This is exactly what I was looking for. I appreciate your effort and time.</description>
    <pubDate>Sun, 03 Sep 2017 18:15:44 GMT</pubDate>
    <dc:creator>benbuck</dc:creator>
    <dc:date>2017-09-03T18:15:44Z</dc:date>
    <item>
      <title>Weight Categorical Variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392782#M94555</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running the below code, attempting to create a table using Proc Tabulate. I am using categorical variables and am attempting to weight observations using the variable "discwt". However, I can't get the weighting to work. Regardless of what I do, my code only produces an unweighted table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running this on SAS 9.4 TS 1M1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data = work.redo_t1;
	title 'Table 1a';
	class cat_flag race ; 
	table race, (cat_flag)*(N colpctn);
	var discwt / weight = discwt;
	weight discwt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Sep 2017 17:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392782#M94555</guid>
      <dc:creator>benbuck</dc:creator>
      <dc:date>2017-09-02T17:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Weight Categorical Variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392787#M94556</link>
      <description>&lt;P&gt;Can you generate some data we can work with to replicate and test your issue?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 19:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392787#M94556</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-02T19:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Weight Categorical Variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392833#M94570</link>
      <description>&lt;P&gt;Here is code to produce sample data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data redo_t1;
	input ID discwt cat_flag race;
	datalines; 
		01 5 1 1
		02 5 1 2
		03 5 1 1
		04 5 1 2
		05 5 1 1
		06 5 3 2
		07 5 3 1
		08 5 3 2
		09 5 3 1
		10 5 3 2
	;
run;

proc tabulate data = work.redo_t1;
	title 'Table 1a';
	class cat_flag race ; 
	table race, (cat_flag)*(N colpctn);
	var discwt / weight = discwt;
	weight discwt;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and i'd like my table to look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cat 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; Cat 3&lt;/P&gt;&lt;P&gt;Region 1 &amp;nbsp; &amp;nbsp; 15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Region 3&amp;nbsp;&amp;nbsp; &amp;nbsp; 10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and not&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cat 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; Cat 3&lt;/P&gt;&lt;P&gt;Region 1 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Region 3&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 02:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392833#M94570</guid>
      <dc:creator>benbuck</dc:creator>
      <dc:date>2017-09-03T02:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Weight Categorical Variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392835#M94571</link>
      <description>&lt;P&gt;You want to use the FREQ option .. NOT the WEIGHT option. e.g.:&lt;/P&gt;
&lt;PRE&gt;data redo_t1;
	input ID discwt cat_flag race;
	datalines; 
		01 5 1 1
		02 5 1 2
		03 5 1 1
		04 5 1 2
		05 5 1 1
		06 5 3 2
		07 5 3 1
		08 5 3 2
		09 5 3 1
		10 5 3 2
	;
run;

proc tabulate data = work.redo_t1;
	title 'Table 1a';
	class cat_flag race ; 
	table race, (cat_flag)*(N colpctn);
	var discwt / weight = discwt;
	freq discwt;
run;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 02:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392835#M94571</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-03T02:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Weight Categorical Variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392868#M94580</link>
      <description>Thank you for your help! This is exactly what I was looking for. I appreciate your effort and time.</description>
      <pubDate>Sun, 03 Sep 2017 18:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/392868#M94580</guid>
      <dc:creator>benbuck</dc:creator>
      <dc:date>2017-09-03T18:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Weight Categorical Variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/477402#M122938</link>
      <description>&lt;P&gt;Your code works fine when the weights are integers , however if the weight are non-integers ,it&amp;nbsp; doesn't give correct results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the sample code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data redo_t1;
	input ID discwt 3.1 cat_flag race;
	datalines; 
		01 0.2 1 1
		02 0.4 1 2
		03 0.4 1 1
		04 0.4 1 2
		05 0.4 1 1
		06 0.1 3 2
		07 1.2 3 1
		08 0.4 3 2
		09 1.0 3 1
		10 0.4 3 2
	;
run;

proc tabulate data = work.redo_t1;
	title 'Table 1a';
	class cat_flag race ; 
	table race, (cat_flag)*(N colpctn);
	var discwt / weight = discwt;
	freq discwt;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I run the attached syntax only the integer part in my weights is used for calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please suggest how to use the solution with the decimal weights.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 11:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/477402#M122938</guid>
      <dc:creator>Bedi</dc:creator>
      <dc:date>2018-07-12T11:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Weight Categorical Variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/477526#M123005</link>
      <description>&lt;P&gt;Try the WEIGHT statement in that case instead of FREQ.&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/144965"&gt;@Bedi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Your code works fine when the weights are integers , however if the weight are non-integers ,it&amp;nbsp; doesn't give correct results&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the sample code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data redo_t1;
	input ID discwt 3.1 cat_flag race;
	datalines; 
		01 0.2 1 1
		02 0.4 1 2
		03 0.4 1 1
		04 0.4 1 2
		05 0.4 1 1
		06 0.1 3 2
		07 1.2 3 1
		08 0.4 3 2
		09 1.0 3 1
		10 0.4 3 2
	;
run;

proc tabulate data = work.redo_t1;
	title 'Table 1a';
	class cat_flag race ; 
	table race, (cat_flag)*(N colpctn);
	var discwt / weight = discwt;
	freq discwt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I run the attached syntax only the integer part in my weights is used for calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please suggest how to use the solution with the decimal weights.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 14:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/477526#M123005</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-12T14:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Weight Categorical Variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/477821#M123132</link>
      <description>&lt;P&gt;Hi..I tried it but than it is giving un-weighted response&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 10:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weight-Categorical-Variables-in-Proc-Tabulate/m-p/477821#M123132</guid>
      <dc:creator>Bedi</dc:creator>
      <dc:date>2018-07-13T10:13:04Z</dc:date>
    </item>
  </channel>
</rss>

