<?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 how to divide two proc tabulate tables through each other without using Excel? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812217#M320446</link>
    <description>&lt;P&gt;Hi, I currently have 2 tables that I produce via proc tabulates using the below code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;title 'TableA';
proc tabulate data = Example out = Numerator;
class GroupA GroupB GroupC GroupD ap_month;
var count one;
table GroupA=''*GroupB=''*GroupC=''*GroupD=''*sum=''*(count*f=comma14.0),month  /nocellmerge;
run;

title 'TableB';
proc tabulate data = Example out = Denominator;
class GroupA GroupB GroupC GroupD month;
var count one;
table GroupA=''*GroupB=''*GroupC=''*GroupD=''*sum=''*(one*f=comma14.0),month  /nocellmerge;
run;&lt;/PRE&gt;
&lt;P&gt;The tables look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tables.png" style="width: 474px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71245iD827D20F88CB60B0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tables.png" alt="Tables.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by dividing through one another you get probabilities and create a probability matrix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what the table is basically saying is, if groupA=1 and GroupB,C,D=0 then probabilities in each month are the top line of the first table divided by the top line of bottom table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create some code that does this dividing to create the same table with probabilities without having to manually divide one table through another in excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know if this is possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NB. the "count variable" represents whether someone has had a certain event (this is what the probabilities relate to - the probabilities of having this event) and the variable "one" is a constant variable that =1 for all observations in the data. If people are in different groups then the probability of having the event is different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2022 17:04:04 GMT</pubDate>
    <dc:creator>EC27556</dc:creator>
    <dc:date>2022-05-09T17:04:04Z</dc:date>
    <item>
      <title>how to divide two proc tabulate tables through each other without using Excel?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812217#M320446</link>
      <description>&lt;P&gt;Hi, I currently have 2 tables that I produce via proc tabulates using the below code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;title 'TableA';
proc tabulate data = Example out = Numerator;
class GroupA GroupB GroupC GroupD ap_month;
var count one;
table GroupA=''*GroupB=''*GroupC=''*GroupD=''*sum=''*(count*f=comma14.0),month  /nocellmerge;
run;

title 'TableB';
proc tabulate data = Example out = Denominator;
class GroupA GroupB GroupC GroupD month;
var count one;
table GroupA=''*GroupB=''*GroupC=''*GroupD=''*sum=''*(one*f=comma14.0),month  /nocellmerge;
run;&lt;/PRE&gt;
&lt;P&gt;The tables look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tables.png" style="width: 474px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71245iD827D20F88CB60B0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tables.png" alt="Tables.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by dividing through one another you get probabilities and create a probability matrix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what the table is basically saying is, if groupA=1 and GroupB,C,D=0 then probabilities in each month are the top line of the first table divided by the top line of bottom table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create some code that does this dividing to create the same table with probabilities without having to manually divide one table through another in excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know if this is possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NB. the "count variable" represents whether someone has had a certain event (this is what the probabilities relate to - the probabilities of having this event) and the variable "one" is a constant variable that =1 for all observations in the data. If people are in different groups then the probability of having the event is different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 17:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812217#M320446</guid>
      <dc:creator>EC27556</dc:creator>
      <dc:date>2022-05-09T17:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to divide two proc tabulate tables through each other without using Excel?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812220#M320448</link>
      <description>Yes, it I would recommend using PROC FREQ to get the counts needed and piping those results to data sets using an OUT= data set. &lt;BR /&gt;Then you can merge the two data sets together and do the calculations necessary. How exactly you do the merge depends on your criteria. Then use PROC REPORT to display the data as needed. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 May 2022 17:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812220#M320448</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-09T17:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to divide two proc tabulate tables through each other without using Excel?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812232#M320452</link>
      <description>Thanks for this. Are you able to provide any example code? I have little experience with Proc Freq and Report!</description>
      <pubDate>Mon, 09 May 2022 17:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812232#M320452</guid>
      <dc:creator>EC27556</dc:creator>
      <dc:date>2022-05-09T17:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to divide two proc tabulate tables through each other without using Excel?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812242#M320456</link>
      <description>&lt;P&gt;Never mind, I've worked it out! Using the output from the above proc tabulates you need to run the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Merged;
merge TableA(drop = _TYPE_ _PAGE_ _TABLE_)
	  TableB(drop = _TYPE_ _PAGE_ _TABLE_);
by GroupA GroupB GroupC GroupD Month;

Probability=Count_Sum/One_Sum;
run;



proc report data=Merged;
	
	column GroupA GroupB GroupC GroupD month,(Probability);
	
	define Month / Across;
	define GroupA / Group;
	define GroupB / Group;
	define GroupC / Group;
	define GroupD / Group;
	define Probability / sum;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 May 2022 18:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-divide-two-proc-tabulate-tables-through-each-other/m-p/812242#M320456</guid>
      <dc:creator>EC27556</dc:creator>
      <dc:date>2022-05-09T18:28:09Z</dc:date>
    </item>
  </channel>
</rss>

