<?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: cumulative pct in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/cummulative-pct/m-p/6870#M2632</link>
    <description>The only tricky part of this process is getting the denominator for each by group and making that available to your unsummarised data.  Since you are working with "by groups", then I'll assume your data are already ordered in group sequence.  If it isn't, then sort the data first.&lt;BR /&gt;
&lt;BR /&gt;
Then summarise the data so you get frequencies for each group.  The Freq procedure is best for this approach and code like the following should suffice.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Proc Freq Data = SERVICES;&lt;BR /&gt;
  By DRG / Output Out = DRGFREQ;&lt;BR /&gt;
Run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Now match merge your two tables using the DRG key.  There will be a column called COUNT, which is the frequency of each DRG group.  You can rename this on merging if a column of the same name already exists on your unsummarised data.&lt;BR /&gt;
&lt;BR /&gt;
Now split your data with code like the following:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Data TOP80&lt;BR /&gt;
        LAST20;&lt;BR /&gt;
  Set SERVICES;&lt;BR /&gt;
  By DRG;&lt;BR /&gt;
  If First.DRG  Then  GROUPFREQ = 0;&lt;BR /&gt;
  GROUPFREQ ++ 1;&lt;BR /&gt;
  If GROUPFREQ / COUNT &amp;lt;= 0.8  Then  Output  TOP80;&lt;BR /&gt;
  Else Output  LAST20;&lt;BR /&gt;
Run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
I don't have a sample of your data, or a structure so the code above is provided as an example only.&lt;BR /&gt;
&lt;BR /&gt;
Good luck.</description>
    <pubDate>Mon, 11 Feb 2008 22:00:14 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-02-11T22:00:14Z</dc:date>
    <item>
      <title>cummulative pct</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/cummulative-pct/m-p/6869#M2631</link>
      <description>I am trying to output the top 80% of the values of a variable &lt;BR /&gt;
across by groups.&lt;BR /&gt;
Ex: top 80% of DRGs (by volume) across hospital service lines.</description>
      <pubDate>Mon, 11 Feb 2008 18:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/cummulative-pct/m-p/6869#M2631</guid>
      <dc:creator>uabcms</dc:creator>
      <dc:date>2008-02-11T18:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative pct</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/cummulative-pct/m-p/6870#M2632</link>
      <description>The only tricky part of this process is getting the denominator for each by group and making that available to your unsummarised data.  Since you are working with "by groups", then I'll assume your data are already ordered in group sequence.  If it isn't, then sort the data first.&lt;BR /&gt;
&lt;BR /&gt;
Then summarise the data so you get frequencies for each group.  The Freq procedure is best for this approach and code like the following should suffice.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Proc Freq Data = SERVICES;&lt;BR /&gt;
  By DRG / Output Out = DRGFREQ;&lt;BR /&gt;
Run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Now match merge your two tables using the DRG key.  There will be a column called COUNT, which is the frequency of each DRG group.  You can rename this on merging if a column of the same name already exists on your unsummarised data.&lt;BR /&gt;
&lt;BR /&gt;
Now split your data with code like the following:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Data TOP80&lt;BR /&gt;
        LAST20;&lt;BR /&gt;
  Set SERVICES;&lt;BR /&gt;
  By DRG;&lt;BR /&gt;
  If First.DRG  Then  GROUPFREQ = 0;&lt;BR /&gt;
  GROUPFREQ ++ 1;&lt;BR /&gt;
  If GROUPFREQ / COUNT &amp;lt;= 0.8  Then  Output  TOP80;&lt;BR /&gt;
  Else Output  LAST20;&lt;BR /&gt;
Run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
I don't have a sample of your data, or a structure so the code above is provided as an example only.&lt;BR /&gt;
&lt;BR /&gt;
Good luck.</description>
      <pubDate>Mon, 11 Feb 2008 22:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/cummulative-pct/m-p/6870#M2632</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-02-11T22:00:14Z</dc:date>
    </item>
  </channel>
</rss>

