<?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: PROC TABULATE: Would like to add some rows that show means, others that show % only if var=&amp;amp;quot in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766737#M30688</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394810"&gt;@keherder&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am wondering if someone can help me create this final table (attached, just refer to the "men" table) using the PROC TABULATE function. I am using the Framingham study data. I've broken age into different age categories called variable "age_category" and number of cigarettes smoked a day into different categories called "cig_category". I am easily able to use the PROC TABULATE function to create a basic table to show the number of a variable for the different catagories:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;PROC TABULATE data=biosc.men_frami_baseline;
CLASS cig_category age_category prevhyp;
TABLE prevhyp, cig_category*age_category;
LABEL cig_category="No. of cigarettes smoked per day" age_category="Age 
Group" prevhyp="Hypertensive";

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This produces a simple table with the number of those who were hypertensive "1" or "0". However, I would like to figure out how to just show the % of total men who were hypertensive="1".&lt;/P&gt;
&lt;P&gt;Additionally, I would like to add the following rows to the same table:&lt;/P&gt;
&lt;P&gt;The total number of participants per group&lt;/P&gt;
&lt;P&gt;The % among the hypertensive who take meds (BPMEDS="1" IF PREVHYP="1")&lt;/P&gt;
&lt;P&gt;The % who are diabetic (DIABETES="1")&lt;/P&gt;
&lt;P&gt;Also, I would like to include rows for the following also by age_category by smoking_category:&lt;/P&gt;
&lt;P&gt;Mean BMI (BMI)&lt;/P&gt;
&lt;P&gt;Mean heart rate (HEARTRTE)&lt;/P&gt;
&lt;P&gt;Mean cholesterol (TOTCHOL)&lt;/P&gt;
&lt;P&gt;I am unsure how to add these specific table elements! Please let me know if I can provide more details. Thank you so much!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software or aren't allowed to due to organization policy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The total number of participants per group. Would be an N statistic somewhere, but you don't mention what defines a group.&lt;/P&gt;
&lt;P&gt;Variables that you want anything other than N or a Percent of N statistic need to go on a VAR statement.&lt;/P&gt;
&lt;P&gt;Then request the desired statistic.&lt;/P&gt;
&lt;P&gt;The % among the hypertensive who take meds (BPMEDS="1" IF PREVHYP="1") without data this may not be easy with the other things you request. It would be better to create another variable that has a value of 1 when BPMEDS="1" IF PREVHYP="1" and 0 when BPMEDS not equal "1" IF PREVHYP="1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If all those variables are actually character variables with values of "1" then make them numeric. Otherwise we get into some not really trivial exercises in excluding stuff from the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The below assumes that some of your variable Prevhyp and Diabetes are &lt;STRONG&gt;numeric coded 1/0&lt;/STRONG&gt; variables. Something like this may get close to the values. No promises about the way the output looks as I don't open Excel from unknown sources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC TABULATE data=biosc.men_frami_baseline;
   CLASS cig_category age_category ;
   var prevhyp bmi totchol HEARTRTE diabetic ;
   TABLE (prevhyp diabetic )*(sum='N' mean='%'*f=percent8.1)
         (bmi totchol HEARTRTE) * mean
       , cig_category*age_category
   ;
   LABEL cig_category="No. of cigarettes smoked per day" 
         age_category="Age Group" 
         prevhyp="Hypertensive"
  ;

run;&lt;/PRE&gt;
&lt;P&gt;You want to post code on the forum by opening a text box or code box by clicking on the &amp;lt;/&amp;gt; or "running man" icon at the top if the message window. Otherwise the forum will reformat code and may create something that won't actually run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Sep 2021 00:52:11 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-09-09T00:52:11Z</dc:date>
    <item>
      <title>PROC TABULATE: Would like to add some rows that show means, others that show % only if var="1"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766726#M30683</link>
      <description>&lt;P&gt;I am wondering if someone can help me create this final table (attached, just refer to the "men" table) using the PROC TABULATE function. I am using the Framingham study data. I've broken age into different age categories called variable "age_category" and number of cigarettes smoked a day into different categories called "cig_category". I am easily able to use the PROC TABULATE function to create a basic table to show the number of a variable for the different catagories:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PROC TABULATE data=biosc.men_frami_baseline;
CLASS cig_category age_category prevhyp;
TABLE prevhyp, cig_category*age_category;
LABEL cig_category="No. of cigarettes smoked per day" age_category="Age 
Group" prevhyp="Hypertensive";

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This produces a simple table with the number of those who were hypertensive "1" or "0". However, I would like to figure out how to just show the % of total men who were hypertensive="1".&lt;/P&gt;&lt;P&gt;Additionally, I would like to add the following rows to the same table:&lt;/P&gt;&lt;P&gt;The total number of participants per group&lt;/P&gt;&lt;P&gt;The % among the hypertensive who take meds (BPMEDS="1" IF PREVHYP="1")&lt;/P&gt;&lt;P&gt;The % who are diabetic (DIABETES="1")&lt;/P&gt;&lt;P&gt;Also, I would like to include rows for the following also by age_category by smoking_category:&lt;/P&gt;&lt;P&gt;Mean BMI (BMI)&lt;/P&gt;&lt;P&gt;Mean heart rate (HEARTRTE)&lt;/P&gt;&lt;P&gt;Mean cholesterol (TOTCHOL)&lt;/P&gt;&lt;P&gt;I am unsure how to add these specific table elements! Please let me know if I can provide more details. Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 23:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766726#M30683</guid>
      <dc:creator>keherder</dc:creator>
      <dc:date>2021-09-08T23:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TABULATE: Would like to add some rows that show means, others that show % only if var=&amp;quot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766730#M30685</link>
      <description>&lt;P&gt;That would be the mean, just format it as a percentage.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you take the mean of a binary variable its the percentage of people with whatever trait = 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the counts/N use the SUM statistic.&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;
&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>Wed, 08 Sep 2021 23:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766730#M30685</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-08T23:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TABULATE: Would like to add some rows that show means, others that show % only if var=&amp;quot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766737#M30688</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394810"&gt;@keherder&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am wondering if someone can help me create this final table (attached, just refer to the "men" table) using the PROC TABULATE function. I am using the Framingham study data. I've broken age into different age categories called variable "age_category" and number of cigarettes smoked a day into different categories called "cig_category". I am easily able to use the PROC TABULATE function to create a basic table to show the number of a variable for the different catagories:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;PROC TABULATE data=biosc.men_frami_baseline;
CLASS cig_category age_category prevhyp;
TABLE prevhyp, cig_category*age_category;
LABEL cig_category="No. of cigarettes smoked per day" age_category="Age 
Group" prevhyp="Hypertensive";

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This produces a simple table with the number of those who were hypertensive "1" or "0". However, I would like to figure out how to just show the % of total men who were hypertensive="1".&lt;/P&gt;
&lt;P&gt;Additionally, I would like to add the following rows to the same table:&lt;/P&gt;
&lt;P&gt;The total number of participants per group&lt;/P&gt;
&lt;P&gt;The % among the hypertensive who take meds (BPMEDS="1" IF PREVHYP="1")&lt;/P&gt;
&lt;P&gt;The % who are diabetic (DIABETES="1")&lt;/P&gt;
&lt;P&gt;Also, I would like to include rows for the following also by age_category by smoking_category:&lt;/P&gt;
&lt;P&gt;Mean BMI (BMI)&lt;/P&gt;
&lt;P&gt;Mean heart rate (HEARTRTE)&lt;/P&gt;
&lt;P&gt;Mean cholesterol (TOTCHOL)&lt;/P&gt;
&lt;P&gt;I am unsure how to add these specific table elements! Please let me know if I can provide more details. Thank you so much!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software or aren't allowed to due to organization policy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The total number of participants per group. Would be an N statistic somewhere, but you don't mention what defines a group.&lt;/P&gt;
&lt;P&gt;Variables that you want anything other than N or a Percent of N statistic need to go on a VAR statement.&lt;/P&gt;
&lt;P&gt;Then request the desired statistic.&lt;/P&gt;
&lt;P&gt;The % among the hypertensive who take meds (BPMEDS="1" IF PREVHYP="1") without data this may not be easy with the other things you request. It would be better to create another variable that has a value of 1 when BPMEDS="1" IF PREVHYP="1" and 0 when BPMEDS not equal "1" IF PREVHYP="1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If all those variables are actually character variables with values of "1" then make them numeric. Otherwise we get into some not really trivial exercises in excluding stuff from the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The below assumes that some of your variable Prevhyp and Diabetes are &lt;STRONG&gt;numeric coded 1/0&lt;/STRONG&gt; variables. Something like this may get close to the values. No promises about the way the output looks as I don't open Excel from unknown sources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC TABULATE data=biosc.men_frami_baseline;
   CLASS cig_category age_category ;
   var prevhyp bmi totchol HEARTRTE diabetic ;
   TABLE (prevhyp diabetic )*(sum='N' mean='%'*f=percent8.1)
         (bmi totchol HEARTRTE) * mean
       , cig_category*age_category
   ;
   LABEL cig_category="No. of cigarettes smoked per day" 
         age_category="Age Group" 
         prevhyp="Hypertensive"
  ;

run;&lt;/PRE&gt;
&lt;P&gt;You want to post code on the forum by opening a text box or code box by clicking on the &amp;lt;/&amp;gt; or "running man" icon at the top if the message window. Otherwise the forum will reformat code and may create something that won't actually run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 00:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766737#M30688</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-09T00:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TABULATE: Would like to add some rows that show means, others that show % only if var=&amp;</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766745#M30690</link>
      <description>They're using the Framingham heart data set, so the SASHELP.HEART data set is pretty much what they have.</description>
      <pubDate>Thu, 09 Sep 2021 01:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-TABULATE-Would-like-to-add-some-rows-that-show-means-others/m-p/766745#M30690</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-09T01:17:07Z</dc:date>
    </item>
  </channel>
</rss>

