<?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: Creating and Comparing Rates between Groups in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887979#M43978</link>
    <description>&lt;P&gt;I'll give that code a shot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;referring to the slopes, this is a graph of the rates when I calculated them manually:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DanielQuay_0-1691187398124.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86471iF84990D40212BE8C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DanielQuay_0-1691187398124.png" alt="DanielQuay_0-1691187398124.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to determine if there is a statistically significant difference between the trend lines.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Aug 2023 22:18:03 GMT</pubDate>
    <dc:creator>DanielQuay</dc:creator>
    <dc:date>2023-08-04T22:18:03Z</dc:date>
    <item>
      <title>Creating and Comparing Rates between Groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887940#M43974</link>
      <description>&lt;P&gt;I am at a bit of a loss.&amp;nbsp; Or perhaps I am once again making things more difficult than they have to be as I am rather good at that.&lt;/P&gt;&lt;P&gt;I'm working with a data set with over 400k observations.&lt;/P&gt;&lt;P&gt;I have a binary variable to indicate whether or not an organization participated (1) in a program or did not (0).&lt;/P&gt;&lt;P&gt;I have another variable which indicates whether an incident happened (1) or did not (0).&lt;/P&gt;&lt;P&gt;I have each of these repeated for 2016-2021.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data = HAVE;&lt;BR /&gt;tables PROGRAM * Incident;&lt;BR /&gt;by year;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can manually calculate the rate per 10,000 and graph that using the code above, but I am looking for a way to calculate the rate within SAS so that I could then determine if there is a difference in the slopes between those that participated in the program and those that did not with regard to incidents.&amp;nbsp; And I'm not sure precisely how to go about that part of things within SAS.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 18:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887940#M43974</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2023-08-04T18:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and Comparing Rates between Groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887947#M43975</link>
      <description>&lt;P&gt;Rate per 10,000 ... what? Show an example of your data. I assume that for each observation in your data you have values for variables indicating organization, year, program participation or not, and incident occurred or not. What are the observations - are there multiple observations for each organization and/or year? The answer will probably involve a modeling approach along the lines of what is shown in &lt;A href="http://support.sas.com/kb/24188" target="_self"&gt;this note&lt;/A&gt; if you really have rates rather than proportions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 20:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887947#M43975</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2023-08-04T20:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and Comparing Rates between Groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887949#M43976</link>
      <description>&lt;P&gt;So, it's per total visits.&lt;/P&gt;&lt;P&gt;Data would be...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year&amp;nbsp; &amp;nbsp; &amp;nbsp;Participant&amp;nbsp; &amp;nbsp; &amp;nbsp;Incident&amp;nbsp; &amp;nbsp; &amp;nbsp;Visit&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output looks like this when I run the table:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;YEAR&lt;/TD&gt;&lt;TD&gt;Program and Incident&lt;/TD&gt;&lt;TD&gt;Not Program and Incident&lt;/TD&gt;&lt;TD&gt;Program and Total Visits&lt;/TD&gt;&lt;TD&gt;Not Program and Total Visits&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2016&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;21903&lt;/TD&gt;&lt;TD&gt;48969&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2017&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;37&lt;/TD&gt;&lt;TD&gt;21637&lt;/TD&gt;&lt;TD&gt;47737&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;TD&gt;26&lt;/TD&gt;&lt;TD&gt;38&lt;/TD&gt;&lt;TD&gt;21608&lt;/TD&gt;&lt;TD&gt;47675&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;43&lt;/TD&gt;&lt;TD&gt;21156&lt;/TD&gt;&lt;TD&gt;46878&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;56&lt;/TD&gt;&lt;TD&gt;20109&lt;/TD&gt;&lt;TD&gt;45540&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021&lt;/TD&gt;&lt;TD&gt;16&lt;/TD&gt;&lt;TD&gt;46&lt;/TD&gt;&lt;TD&gt;19134&lt;/TD&gt;&lt;TD&gt;43691&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 04 Aug 2023 20:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887949#M43976</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2023-08-04T20:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and Comparing Rates between Groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887976#M43977</link>
      <description>&lt;P&gt;When you have 1/0 coded variables then the MEAN of the variables is in effect the percent of 1s in the values.&lt;/P&gt;
&lt;P&gt;Percent when multiplied by 100 is "rate per hundred". Multiplied by 10,000 it would be rate per 10,000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you do something like:&lt;/P&gt;
&lt;PRE&gt;proc means data=have nway;
   class year program;
   var incident;&lt;BR /&gt;   output out=summary mean=;
run;&lt;/PRE&gt;
&lt;P&gt;You will have the incident percentage per level of the Program variable. Then use the Summary data set created to make the per 10,000 instead of per 100. IF any of your Visit values is ever other than 1 you would use that variable as a FREQ variable to indicate that observation represents more than one visit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am confused about your proc freq code with variables Program and Incident and your example data with Participant and Incident though. There seems to be a disconnect in your description and or the "rates" you might be talking about.&lt;/P&gt;
&lt;P&gt;It is always a very good idea to very clearly state what the numerator and denominator of a rate should be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also confused about "slopes" as there isn't any obvious to me.&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>Fri, 04 Aug 2023 22:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887976#M43977</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-04T22:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and Comparing Rates between Groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887979#M43978</link>
      <description>&lt;P&gt;I'll give that code a shot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;referring to the slopes, this is a graph of the rates when I calculated them manually:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DanielQuay_0-1691187398124.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86471iF84990D40212BE8C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DanielQuay_0-1691187398124.png" alt="DanielQuay_0-1691187398124.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to determine if there is a statistically significant difference between the trend lines.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 22:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887979#M43978</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2023-08-04T22:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and Comparing Rates between Groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887983#M43979</link>
      <description>&lt;P&gt;This reads your data and plots the rates per 10k:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a; input year a b c d; 
yearindx=year-2015;
program=1; NumInc=a; rateden=log(c/10000); rate=a/(c/10000); output;
program=0; NumInc=b; rateden=log(d/10000); rate=b/(d/10000); output;
datalines;
2016    33      52      21903   48969
2017    23      37      21637   47737
2018    26      38      21608   47675
2019    30      43      21156   46878
2020    24      56      20109   45540
2021    16      46      19134   43691
;
proc sgplot;
scatter y=rate x=year / group=program;
series y=rate x=year / group=program;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Because the trends are pretty clearly nonlinear, it would be a mistake to just fit lines to the two program groups and compare their slopes. These curves appear approximately cubic. To compare the trends over time, you can follow the approach discussed and illustrated with a rates model in &lt;A href="https://support.sas.com/kb/24/177.html" target="_self"&gt;this note&lt;/A&gt;, but modified to allow for cubic fits. Note that it is better to not use the actual year values when modeling because they are so large.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod;
class program;
model NumInc = program|yearindx|yearindx|yearindx / dist=poisson noint offset=rateden;
effectplot / moff obs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The results show that the program trends don't differ significantly - the differences between programs on the linear, quadratic, and cubic components (program*yearindx, program*yearindx*yearindx, and program*yearindx*yearindx*yearindx) are not significant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 23:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/887983#M43979</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2023-08-04T23:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and Comparing Rates between Groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/888354#M44000</link>
      <description>&lt;P&gt;That is was precisely what I was struggling to do.&amp;nbsp; Everything I had tried up to now got me close but didn't seem exactly right.&lt;BR /&gt;I can't thank you enough mate, now I get to learn about cubic relationships and I really appreciate the note you attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 13:27:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-and-Comparing-Rates-between-Groups/m-p/888354#M44000</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2023-08-08T13:27:03Z</dc:date>
    </item>
  </channel>
</rss>

