<?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: How to generate weighted count and column percentage from proc tabulate in SAS Studio in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832804#M329208</link>
    <description>&lt;P&gt;And what is the weight variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show some sample data, in the form of a working data step.&lt;/P&gt;
&lt;P&gt;And the expected result.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2022 01:39:13 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-09-12T01:39:13Z</dc:date>
    <item>
      <title>How to generate weighted count and column percentage from proc tabulate in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832790#M329197</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having a hard time editing the following code to generate weighted N and column percentage using proc tabulate. My dataset is survey design but only has weights and no strata nor cluster. My expected result is to have weighted frequency of lab test outcome by condition and race group.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using survey frequency is less flexible compared to tabulate in term of table format.&lt;/P&gt;&lt;P&gt;Any help on rewriting the code is greatly appreciated!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc tabulate data=test(where=(cohort=1)) noseps  ;
class flag_A1C9_lst  Cat_raceeth obesity Hyperlipidemia Hypertension ;
table flag_A1C9_lst,(all  obesity*Cat_raceeth 
					 Hyperlipidemia*Cat_raceeth 
					 Hypertension*Cat_raceeth)*(n*f=comma8. colPctN*f=4.1);				 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Sep 2022 22:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832790#M329197</guid>
      <dc:creator>Crystal_F</dc:creator>
      <dc:date>2022-09-11T22:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate weighted count and column percentage from proc tabulate in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832804#M329208</link>
      <description>&lt;P&gt;And what is the weight variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show some sample data, in the form of a working data step.&lt;/P&gt;
&lt;P&gt;And the expected result.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 01:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832804#M329208</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-09-12T01:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate weighted count and column percentage from proc tabulate in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832905#M329246</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data sample;
  input uniqueid $ flag_A1C9_lst Cat_raceeth obesity Hyperlipidemia Hypertension cohort FWGT_2019
        ;
datalines;
1 1 1 1 1 0 1 1473
2 0 2 0 1 1 0 2296
3 . 3 1 0 1 1 7484
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The expected output looks like below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="table example.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75152i61147AD9E634EE6A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="table example.png" alt="table example.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 14:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832905#M329246</guid>
      <dc:creator>Crystal_F</dc:creator>
      <dc:date>2022-09-12T14:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate weighted count and column percentage from proc tabulate in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832911#M329248</link>
      <description>&lt;P&gt;What do you get when you add a Weight statement to your proc tabulate:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;proc tabulate data=test(where=(cohort=1)) noseps  ;
class flag_A1C9_lst  Cat_raceeth obesity Hyperlipidemia Hypertension ;&lt;BR /&gt;weight FWGT_2019;
table flag_A1C9_lst,(all  obesity*Cat_raceeth 
					 Hyperlipidemia*Cat_raceeth 
					 Hypertension*Cat_raceeth)*(n*f=comma8. colPctN*f=4.1);				 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your variable FWGT_2019 is actually a count variable, such as from summarizing data, you may actually want a FREQ statement instead of weight. &lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 14:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832911#M329248</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-12T14:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate weighted count and column percentage from proc tabulate in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832957#M329270</link>
      <description>Thank you for your reply! Adding weight statement alone couldn't generate weighted N and weighted column percentage from 'n*f=comma8. colPctN*f=4.1' in SAS Studio.</description>
      <pubDate>Mon, 12 Sep 2022 17:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832957#M329270</guid>
      <dc:creator>Crystal_F</dc:creator>
      <dc:date>2022-09-12T17:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate weighted count and column percentage from proc tabulate in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832958#M329271</link>
      <description>&lt;P&gt;FREQ seems to work?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input uniqueid $ flag_A1C9_lst Cat_raceeth obesity Hyperlipidemia Hypertension cohort FWGT_2019
        ;
datalines;
1 1 1 1 1 0 1 1473
2 0 2 0 1 1 0 2296
3 . 3 1 0 1 1 7484
;
run;

 

proc tabulate data=sample(where=(cohort=1)) noseps  ;
class flag_A1C9_lst  Cat_raceeth obesity Hyperlipidemia Hypertension / missing ;
freq FWGT_2019;
table flag_A1C9_lst,(all  obesity*Cat_raceeth 
					 Hyperlipidemia*Cat_raceeth 
					 Hypertension*Cat_raceeth)*(n*f=comma8. colPctN*f=4.1);				 
run; &lt;/CODE&gt;&lt;/PRE&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>Mon, 12 Sep 2022 17:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/832958#M329271</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-12T17:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate weighted count and column percentage from proc tabulate in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/833213#M329369</link>
      <description>&lt;P&gt;Yes, using freq statement instead really works. Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for your great suggestions!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 19:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-weighted-count-and-column-percentage-from-proc/m-p/833213#M329369</guid>
      <dc:creator>Crystal_F</dc:creator>
      <dc:date>2022-09-13T19:00:34Z</dc:date>
    </item>
  </channel>
</rss>

