<?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 calculate the proportion of a modality of a binary variable in proc tabulate? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-proportion-of-a-modality-of-a-binary/m-p/810242#M319510</link>
    <description>&lt;PRE class=""&gt;&lt;SPAN class=""&gt;Thank you for your reply.&lt;BR /&gt; I have summarized the problem. Otherwise I work with a big data where I will have three variables of respective &lt;BR /&gt;alphanumeric, numeric and binary types. And I want to write a program that will output me that every time my data changes &lt;BR /&gt;a table in the same format as in the word document.&lt;/SPAN&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Apr 2022 17:31:10 GMT</pubDate>
    <dc:creator>Child79</dc:creator>
    <dc:date>2022-04-27T17:31:10Z</dc:date>
    <item>
      <title>How to calculate the proportion of a modality of a binary variable in proc tabulate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-proportion-of-a-modality-of-a-binary/m-p/809751#M319329</link>
      <description>&lt;DIV class=""&gt;&lt;PRE class=""&gt;&lt;SPAN class=""&gt;I have data on 50 (20 girls, 30 boys) students.&lt;BR /&gt;I have a total of 35 (15 Girls, 20 Boys) students who passed their Maths exam.&lt;BR /&gt; In my database I have 3 variables: &lt;STRONG&gt;Gender,nb_books , result&lt;/STRONG&gt;. The results variable is a binary variable&lt;BR /&gt; taking the values ​​Yes or No. (Yes if the student passed his Mathematics exam, No if the student failed). &lt;BR /&gt;I want to create a summary table where in columns I will have the sum of the number of books in mathematics, number of&lt;BR /&gt;student that passed the exam and the proportion of students who passed the exam. And I will have on the line the variable&lt;BR /&gt;gender. But I don't know how to calculate the proportions in the table. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=""&gt;&lt;SPAN class=""&gt;I converted the result variable into a  numeric variable named &lt;STRONG&gt;num_result&lt;/STRONG&gt;.So I created a &lt;STRONG&gt;prob&lt;/STRONG&gt; variable by using &lt;BR /&gt;variable result defined as follows: &lt;BR /&gt;- 1/20 if it is a girl who passed her exam &lt;BR /&gt;-0 if it is a girl who did not pass her exam.&lt;BR /&gt; -1/30 if it is a boy who passed his exam &lt;BR /&gt;-0 if it is a boy who did not pass his exam.&lt;BR /&gt;And I used sum in a &lt;STRONG&gt;proc tabulate&lt;/STRONG&gt; to get the summary table.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=""&gt;&lt;SPAN class=""&gt;But the total for the &lt;STRONG&gt;prob&lt;/STRONG&gt; variable exceeds 1. Which is not good because I want it to equal 35/50. I used this code. &lt;BR /&gt;I will appreciate your help.&lt;BR /&gt;I used SAS EG. See my attached files for examples.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc tabulate data=students;
var num_result nb_books prob;
class gender;
TABLE 
/* Row statement */
gender
all = 'Total',
/* column statement */
(num_result = ' ' * Sum={LABEL="Number of student that passed the exam"} nb_books = ' ' * Sum={LABEL="Number of mathematics books"} prob= ' ' * Sum={LABEL= " Proportion of student who passed the exam" );
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE class=""&gt;&amp;nbsp;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 25 Apr 2022 17:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-proportion-of-a-modality-of-a-binary/m-p/809751#M319329</guid>
      <dc:creator>Child79</dc:creator>
      <dc:date>2022-04-25T17:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the proportion of a modality of a binary variable in proc tabulate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-proportion-of-a-modality-of-a-binary/m-p/809862#M319387</link>
      <description>&lt;P&gt;There are many ways to do this.... are you required to use PROC SUMMARY? I would use PROC FREQ for this task, as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Students;
length Sex $6;
input Sex $ Count Pass;
datalines;
Male 20 1
Male 10 0
Female 15 1
Female  5 0
;

proc freq data=Students;
tables Sex*Pass / norow nocol out=FreqOut;
weight Count;
run;

proc print data=FreqOut;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Apr 2022 13:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-proportion-of-a-modality-of-a-binary/m-p/809862#M319387</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-04-26T13:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the proportion of a modality of a binary variable in proc tabulate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-proportion-of-a-modality-of-a-binary/m-p/810242#M319510</link>
      <description>&lt;PRE class=""&gt;&lt;SPAN class=""&gt;Thank you for your reply.&lt;BR /&gt; I have summarized the problem. Otherwise I work with a big data where I will have three variables of respective &lt;BR /&gt;alphanumeric, numeric and binary types. And I want to write a program that will output me that every time my data changes &lt;BR /&gt;a table in the same format as in the word document.&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2022 17:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-proportion-of-a-modality-of-a-binary/m-p/810242#M319510</guid>
      <dc:creator>Child79</dc:creator>
      <dc:date>2022-04-27T17:31:10Z</dc:date>
    </item>
  </channel>
</rss>

