<?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 do I calculate a rate by group? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-calculate-a-rate-by-group/m-p/952863#M42812</link>
    <description>&lt;P&gt;I have a dataset where I need to calculate the rate of opioid episodes (OpioidEpisodes/TotalEpisodes) by county. I have spent many hours trying to come up with the right code. Can someone please tell me if I'm on the right track?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20241207_164549[1].jpg" style="width: 749px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102785i5A4955249BAA76D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="20241207_164549[1].jpg" alt="20241207_164549[1].jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20241207_162841[1].jpg" style="width: 749px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102787iDAEA5E04F62CEF72/image-size/large?v=v2&amp;amp;px=999" role="button" title="20241207_162841[1].jpg" alt="20241207_162841[1].jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 07 Dec 2024 23:32:39 GMT</pubDate>
    <dc:creator>KimW</dc:creator>
    <dc:date>2024-12-07T23:32:39Z</dc:date>
    <item>
      <title>How do I calculate a rate by group?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-calculate-a-rate-by-group/m-p/952863#M42812</link>
      <description>&lt;P&gt;I have a dataset where I need to calculate the rate of opioid episodes (OpioidEpisodes/TotalEpisodes) by county. I have spent many hours trying to come up with the right code. Can someone please tell me if I'm on the right track?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20241207_164549[1].jpg" style="width: 749px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102785i5A4955249BAA76D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="20241207_164549[1].jpg" alt="20241207_164549[1].jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20241207_162841[1].jpg" style="width: 749px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102787iDAEA5E04F62CEF72/image-size/large?v=v2&amp;amp;px=999" role="button" title="20241207_162841[1].jpg" alt="20241207_162841[1].jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2024 23:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-calculate-a-rate-by-group/m-p/952863#M42812</guid>
      <dc:creator>KimW</dc:creator>
      <dc:date>2024-12-07T23:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I calculate a rate by group?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-calculate-a-rate-by-group/m-p/952864#M42813</link>
      <description>&lt;P&gt;This looks very close to me, small changes needed to PROC SUMMARY. You need a data step after PROC SUMMARY to do the actual division from the results in data set TOTALS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=____________ nway;
    class county;
    var opioidepisodes totalepisodes;
    output out=totals sum=;
run;

data totals1;
    set totals;
    rate=opioidepisodes/totalepisodes;
run;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: When you want to show us your code, copy it as text and paste it into the window that appears when you click on the "little running man" icon. Making screen captures of text is not a good thing to do.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2024 00:34:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-calculate-a-rate-by-group/m-p/952864#M42813</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-12-08T00:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I calculate a rate by group?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-calculate-a-rate-by-group/m-p/952919#M42814</link>
      <description>&lt;P&gt;IF, and I know this is a big if, your variables are numeric coded as 0 and 1 then the MEAN of the variable is the percent of 1 values for the non-missings.&lt;/P&gt;
&lt;P&gt;Example if your OpiodEpisodes have 30 1 values and 20 0 values then the mean would be 30/50 or 0.60 meaning 60 percent.&lt;/P&gt;
&lt;P&gt;If that seems likely to be valid for your data I would expect something like this might work.&lt;/P&gt;
&lt;PRE&gt;Proc summary data=mydata.opioidcounty;
  by county payer; /*Or use class county payer; */
  var opioidEpisodes TotalEpisodes;
  output out=totals Sum= OpioidEpisodes TotalEpisodes mean=opioidpercentage    totalpercentage;
run;&lt;/PRE&gt;
&lt;P&gt;I say "something like" as I very strongly suspect the output you show does not come from the code shown. The Var variables shown would have a hard time generating an output variable named TotalEpisodes because your code includes a space in the name. Also since the var Payer was not one the output statement by name it would not be included in the output.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 03:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-calculate-a-rate-by-group/m-p/952919#M42814</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-12-09T03:46:58Z</dc:date>
    </item>
  </channel>
</rss>

