<?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: Best way to sum counts of a variable by group? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-sum-counts-of-a-variable-by-group/m-p/742906#M232483</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297876"&gt;@SAS93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have two variables from a dataset: county and facilityname.&lt;/P&gt;
&lt;P&gt;I want to essentially see the county "spread" of each facility, so I can see which facilities are most frequently serviced by each county and vice versa.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I could do a crosstab using proc freq of these two variables, I want to get a more "summarized" output because there are 100-150 different facility names and about 100 counties.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using the FIRST.facilityname by county approach, but that severely limited my overall output/number of observations.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm afraid that you may need to provide some example of what you mean by "more "summarized" output.&lt;/P&gt;
&lt;P&gt;It also sounds like you may not be sure just how many facility names are involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc summary data=have nway;
   class facility county;
   output out=summary (drop=_type_);
run;
&lt;/PRE&gt;
&lt;P&gt;Will generate a data set with just the counts of facilty county combinations in your data set. The variable _freq_ will have the count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can change the order of the variables on the Class statement to get the output in different order or sort the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 May 2021 14:31:06 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-05-21T14:31:06Z</dc:date>
    <item>
      <title>Best way to sum counts of a variable by group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-sum-counts-of-a-variable-by-group/m-p/742887#M232468</link>
      <description>&lt;P&gt;I have two variables from a dataset: county and facilityname.&lt;/P&gt;
&lt;P&gt;I want to essentially see the county "spread" of each facility, so I can see which facilities are most frequently serviced by each county and vice versa.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I could do a crosstab using proc freq of these two variables, I want to get a more "summarized" output because there are 100-150 different facility names and about 100 counties.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using the FIRST.facilityname by county approach, but that severely limited my overall output/number of observations.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 13:11:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-sum-counts-of-a-variable-by-group/m-p/742887#M232468</guid>
      <dc:creator>SAS93</dc:creator>
      <dc:date>2021-05-21T13:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to sum counts of a variable by group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-sum-counts-of-a-variable-by-group/m-p/742906#M232483</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297876"&gt;@SAS93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have two variables from a dataset: county and facilityname.&lt;/P&gt;
&lt;P&gt;I want to essentially see the county "spread" of each facility, so I can see which facilities are most frequently serviced by each county and vice versa.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I could do a crosstab using proc freq of these two variables, I want to get a more "summarized" output because there are 100-150 different facility names and about 100 counties.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using the FIRST.facilityname by county approach, but that severely limited my overall output/number of observations.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm afraid that you may need to provide some example of what you mean by "more "summarized" output.&lt;/P&gt;
&lt;P&gt;It also sounds like you may not be sure just how many facility names are involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc summary data=have nway;
   class facility county;
   output out=summary (drop=_type_);
run;
&lt;/PRE&gt;
&lt;P&gt;Will generate a data set with just the counts of facilty county combinations in your data set. The variable _freq_ will have the count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can change the order of the variables on the Class statement to get the output in different order or sort the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 14:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-sum-counts-of-a-variable-by-group/m-p/742906#M232483</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-21T14:31:06Z</dc:date>
    </item>
  </channel>
</rss>

