<?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: Tabulate row percentages by category with missing values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Tabulate-row-percentages-by-category-with-missing-values/m-p/195804#M48987</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahhhhh, so easy!!! Thank you so much!! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Apr 2015 19:34:17 GMT</pubDate>
    <dc:creator>shailey</dc:creator>
    <dc:date>2015-04-14T19:34:17Z</dc:date>
    <item>
      <title>Tabulate row percentages by category with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tabulate-row-percentages-by-category-with-missing-values/m-p/195802#M48985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I frequently analyze survey research where I would like to calculate row percents by category for several variables. The problem arises when there are different missing values for each variable. For example, imagine 10 people answered a survey with 5 questions (Q1-Q5). Person 1 answered all 5 questions, Person 2 skipped Q3, Person 3 skipped Q2, Person 4 skipped Q1, and so on. So when I calculate the percentages for each question, I want it to be the percentage of people who answered each question, not the total number who participated in the survey. Because the missing values vary I can't set them as class variables. I can set them as var variables easily enough, and I can get the count of the 1s and the count of the non-missing values, but I can't for the life of me figure out how to get the percentage by category.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To give an example of what my data look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input category $ Q1 Q2 Q3 Q4 Q5;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;a 1 0 1 0 1&lt;/P&gt;&lt;P&gt;b 1 1 . 1 0&lt;/P&gt;&lt;P&gt;a 0 . 1 1 0&lt;/P&gt;&lt;P&gt;b . 0 1 0 1&lt;/P&gt;&lt;P&gt;a 1 0 1 . 0&lt;/P&gt;&lt;P&gt;b 0 1 0 1 0&lt;/P&gt;&lt;P&gt;a . 1 0 1 0&lt;/P&gt;&lt;P&gt;b 1 0 0 0 0&lt;/P&gt;&lt;P&gt;a 1 0 0 1 1&lt;/P&gt;&lt;P&gt;b 0 1 1 . 0&lt;/P&gt;&lt;P&gt;a 1 0 . 1 1&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know I'm doing something wrong, but this table has the correct counts:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc tabulate data = test format = comma6.;&lt;/P&gt;&lt;P&gt;class category;&lt;/P&gt;&lt;P&gt;var Q1-Q5;&lt;/P&gt;&lt;P&gt;tables&lt;/P&gt;&lt;P&gt;q1-q5, (all category)* (all n);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the "Sum" has the count of 1s, and the N has the count of the 1s and 0s. (i'm not exactly sure where the sum came from, which is part of why I'm sure I'm doing something wrong).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table below is laid out exactly how I would want, except I would like to add another column for each category that has the percent by category for each of the Q1-Q5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc tabulate data = test format = comma6.;&lt;/P&gt;&lt;P&gt;class category;&lt;/P&gt;&lt;P&gt;var Q1-Q5;&lt;/P&gt;&lt;P&gt;tables Q1-Q5, (all = "All" category = "") * (all = "" n = "Total") / row = float;&lt;/P&gt;&lt;P&gt;keylabel sum = "1s";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So for example, Q1 would be 5/8 = 63% overall, 75% for category a, and 50% for category b.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe I am going about this totally the wrong way, so if anyone has any suggestions I'd really appreciate it! This comes up very frequently for me so I'd really like to find a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 19:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tabulate-row-percentages-by-category-with-missing-values/m-p/195802#M48985</guid>
      <dc:creator>shailey</dc:creator>
      <dc:date>2015-04-14T19:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Tabulate row percentages by category with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tabulate-row-percentages-by-category-with-missing-values/m-p/195803#M48986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With 0/1 coded values such as you are using N = number responses, Mean= Percent of responses&lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;table Q1-Q5, (all = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: SAS Monospace;"&gt;"All"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt; category = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: SAS Monospace;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;) * (all = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: SAS Monospace;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt; n = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: SAS Monospace;"&gt;"Total"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt; mean=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: SAS Monospace;"&gt;'%'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;*&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: SAS Monospace;"&gt;f&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #804040; font-size: 10pt; font-family: SAS Monospace;"&gt;percent8.1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;) / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: SAS Monospace;"&gt;row&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: SAS Monospace;"&gt;float&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 19:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tabulate-row-percentages-by-category-with-missing-values/m-p/195803#M48986</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-04-14T19:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Tabulate row percentages by category with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tabulate-row-percentages-by-category-with-missing-values/m-p/195804#M48987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahhhhh, so easy!!! Thank you so much!! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 19:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tabulate-row-percentages-by-category-with-missing-values/m-p/195804#M48987</guid>
      <dc:creator>shailey</dc:creator>
      <dc:date>2015-04-14T19:34:17Z</dc:date>
    </item>
  </channel>
</rss>

