<?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 Proc Freq, with different groups in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Proc-Freq-with-different-groups/m-p/41672#M2778</link>
    <description>Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Currently I have a stored process that does a proc freq on a table of data.  The 2 columns of interest are Facility and Contacts.  I have a filter setup in the stored process to filter on the Facility.  The table looks like this:&lt;BR /&gt;
&lt;BR /&gt;
Facility, Contacts&lt;BR /&gt;
A, 1&lt;BR /&gt;
A, 2&lt;BR /&gt;
B, 3&lt;BR /&gt;
B, 10&lt;BR /&gt;
C, 15&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Now... in my stored process has the following code:&lt;BR /&gt;
proc sort data=opmetric.sas_geo_2010all out=barron;&lt;BR /&gt;
   by descending facilityname descending contacts;&lt;BR /&gt;
   where state in (%stringGen(parm=state)) and facilityname in (%stringGen(parm=facility)); run;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=barron order=data noprint;&lt;BR /&gt;
   tables state*city*facilityname  / list out=contacts;&lt;BR /&gt;
    weight contacts;&lt;BR /&gt;
run;&lt;BR /&gt;
data finalcontacts (drop=percent);&lt;BR /&gt;
set contacts;&lt;BR /&gt;
cumcontacts+percent;&lt;BR /&gt;
run;&lt;BR /&gt;
data sasbase.geo2010all;&lt;BR /&gt;
    merge barron (in=c) finalcontacts (in=a) finalrounds (in=b);&lt;BR /&gt;
    if c;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Now when I run this, this will calculate the frequency and cumulative % for each facility that I supply in the filter.  So if I supplied Facilities A and B, the ending table would look like:&lt;BR /&gt;
Facility, Contacts, % of Total, Cum %&lt;BR /&gt;
A, 1, 6.25%, 6.25%&lt;BR /&gt;
A, 2, 12.5%, 18.75%&lt;BR /&gt;
B, 3, 18.75%, 37.50%&lt;BR /&gt;
B, 10, 62.50%, 100%&lt;BR /&gt;
&lt;BR /&gt;
However, what I would like for it to do is break out a cumulative % per Facility, instead of lumping every facility from the filter together.  So Facility A would have its own cumulative %, then Facility B would have its own cumulative %.  etc&lt;BR /&gt;
&lt;BR /&gt;
Hope this makes sense&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
    <pubDate>Tue, 30 Nov 2010 21:26:16 GMT</pubDate>
    <dc:creator>bcwhiteh</dc:creator>
    <dc:date>2010-11-30T21:26:16Z</dc:date>
    <item>
      <title>Proc Freq, with different groups</title>
      <link>https://communities.sas.com/t5/Developers/Proc-Freq-with-different-groups/m-p/41672#M2778</link>
      <description>Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Currently I have a stored process that does a proc freq on a table of data.  The 2 columns of interest are Facility and Contacts.  I have a filter setup in the stored process to filter on the Facility.  The table looks like this:&lt;BR /&gt;
&lt;BR /&gt;
Facility, Contacts&lt;BR /&gt;
A, 1&lt;BR /&gt;
A, 2&lt;BR /&gt;
B, 3&lt;BR /&gt;
B, 10&lt;BR /&gt;
C, 15&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Now... in my stored process has the following code:&lt;BR /&gt;
proc sort data=opmetric.sas_geo_2010all out=barron;&lt;BR /&gt;
   by descending facilityname descending contacts;&lt;BR /&gt;
   where state in (%stringGen(parm=state)) and facilityname in (%stringGen(parm=facility)); run;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=barron order=data noprint;&lt;BR /&gt;
   tables state*city*facilityname  / list out=contacts;&lt;BR /&gt;
    weight contacts;&lt;BR /&gt;
run;&lt;BR /&gt;
data finalcontacts (drop=percent);&lt;BR /&gt;
set contacts;&lt;BR /&gt;
cumcontacts+percent;&lt;BR /&gt;
run;&lt;BR /&gt;
data sasbase.geo2010all;&lt;BR /&gt;
    merge barron (in=c) finalcontacts (in=a) finalrounds (in=b);&lt;BR /&gt;
    if c;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Now when I run this, this will calculate the frequency and cumulative % for each facility that I supply in the filter.  So if I supplied Facilities A and B, the ending table would look like:&lt;BR /&gt;
Facility, Contacts, % of Total, Cum %&lt;BR /&gt;
A, 1, 6.25%, 6.25%&lt;BR /&gt;
A, 2, 12.5%, 18.75%&lt;BR /&gt;
B, 3, 18.75%, 37.50%&lt;BR /&gt;
B, 10, 62.50%, 100%&lt;BR /&gt;
&lt;BR /&gt;
However, what I would like for it to do is break out a cumulative % per Facility, instead of lumping every facility from the filter together.  So Facility A would have its own cumulative %, then Facility B would have its own cumulative %.  etc&lt;BR /&gt;
&lt;BR /&gt;
Hope this makes sense&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Tue, 30 Nov 2010 21:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Proc-Freq-with-different-groups/m-p/41672#M2778</guid>
      <dc:creator>bcwhiteh</dc:creator>
      <dc:date>2010-11-30T21:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq, with different groups</title>
      <link>https://communities.sas.com/t5/Developers/Proc-Freq-with-different-groups/m-p/41673#M2779</link>
      <description>Two solutions I can think of:&lt;BR /&gt;
&lt;BR /&gt;
1 - Use a By statement to get the breakout for groups. However, I suspect you also want the overall value.&lt;BR /&gt;
&lt;BR /&gt;
2 - I would use Proc Tabulate or Report for this particular application.</description>
      <pubDate>Wed, 01 Dec 2010 10:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Proc-Freq-with-different-groups/m-p/41673#M2779</guid>
      <dc:creator>TriciaA</dc:creator>
      <dc:date>2010-12-01T10:06:23Z</dc:date>
    </item>
  </channel>
</rss>

