<?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: Grouping by frequencies with more than one variable? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650830#M31245</link>
    <description>&lt;P&gt;It helps to show what you would expect as a result from your given example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can see something like using Proc Freq to count the person/service combinations sending that to a data set and then summarizing the "count" by the service type. Not terribly difficult or complex but we do need to know what you want as a final result.&lt;/P&gt;</description>
    <pubDate>Tue, 26 May 2020 16:40:35 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-05-26T16:40:35Z</dc:date>
    <item>
      <title>Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650817#M31243</link>
      <description>&lt;DIV class="tgml wordwrap"&gt;Hello,&lt;BR /&gt;I am working with this large dataset that looks at a number of different patients receiving services dating back from five years ago. Now each patient is given a unique id number, but there are duplicates in the dataset because an individual could receive multiple different services or come in on different dates for the same service. I want to specifically focus on two distinct services and group individuals based on the number of times they received either service (i.e. Received once, twice,...,6+). Being that I would have to group probably on only id number and service type, I would like any recommendation on how to approach this. I made a small scale example of what my data set looks like. Thank you and I appreciate any help&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;ID Number Date Agency Service&lt;BR /&gt;0012 5/1/2020 Hospital A X Ray&lt;BR /&gt;0012 5/1/2020 Hospital A Lab Work&lt;BR /&gt;0012 5/5/2020 Clinic D Lab Work&lt;BR /&gt;0014 5/1/2020 Hospital A MRI&lt;BR /&gt;0014 5/1/2020 Hospital A Physical Therapy&lt;BR /&gt;0020 5/3/2020 Hospital B Lab Work&lt;BR /&gt;0021 5/1/2020 Hospital A X Ray&lt;BR /&gt;0021 5/1/2020 Hospital A Lab Work&lt;BR /&gt;0021 5/1/2020 Community Clinic Physical Therapy&lt;BR /&gt;0021 5/5/2020 Hospital A Lab Work&lt;BR /&gt;0021 5/5/2020 Hospital A Referral&lt;BR /&gt;0021 5/10/2020 Clinic D Lab Work&lt;/DIV&gt;</description>
      <pubDate>Tue, 26 May 2020 16:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650817#M31243</guid>
      <dc:creator>edwardar126</dc:creator>
      <dc:date>2020-05-26T16:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650820#M31244</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
&amp;nbsp; &amp;nbsp; &amp;nbsp;tables id*service/list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 May 2020 16:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650820#M31244</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-26T16:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650830#M31245</link>
      <description>&lt;P&gt;It helps to show what you would expect as a result from your given example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can see something like using Proc Freq to count the person/service combinations sending that to a data set and then summarizing the "count" by the service type. Not terribly difficult or complex but we do need to know what you want as a final result.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 16:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650830#M31245</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-26T16:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650834#M31246</link>
      <description>Thank you for the suggestion. I actually did this, but my concern being that since my dataset is 100,000+ I get a large list of patients and I would still need to group each individuals. I'm thinking about creating another variable for this step.</description>
      <pubDate>Tue, 26 May 2020 16:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650834#M31246</guid>
      <dc:creator>edwardar126</dc:creator>
      <dc:date>2020-05-26T16:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650841#M31247</link>
      <description>&lt;P&gt;Proc SQL gives you lots of flexibility to do this kind of grouping:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
    count(id) as count,
    *
from have
group by ID, service;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Count 	ID 	Date 	        Agency 	        Service
2 	12 	2020-05-01 	Hospital A 	Lab Work
2 	12 	2020-05-05 	Clinic D 	Lab Work
1 	12 	2020-05-01 	Hospital A 	X Ray
1 	14 	2020-05-01 	Hospital A 	MRI
1 	14 	2020-05-01 	Hospital A 	Physical Therapy
1 	20 	2020-05-03 	Hospital B 	Lab Work
3 	21 	2020-05-10 	Clinic D 	Lab Work
3 	21 	2020-05-05 	Hospital A 	Lab Work
3 	21 	2020-05-01 	Hospital A 	Lab Work
1 	21 	2020-05-01 	Community Clinic 	Physical Therapy
1 	21 	2020-05-05 	Hospital A 	Referral
1 	21 	2020-05-01 	Hospital A 	X Ray&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 May 2020 16:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650841#M31247</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-05-26T16:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650842#M31248</link>
      <description>Hey, I apologize for not further clarifying from the beginning. Ultimately, I am only interested in patients receiving two specific services. So in my example, I'm really interested in individuals who received either 'lab work' or 'x ray'. What I will do then is group individuals by the number of times they received either service, in this case how many individuals 'received a service at least once', 'at least twice', … ,or '6+', so in the example above individual 0012 would be grouped as having a frequency of 3 times (received an x ray once and received lab work twice). My first step that I've done was create an IF statement to just focus on the two specific service, but now I am also considering creating a new variable. I don't think a Proc Freq will capture what I want to accomplish being that my dataset is set more than 100,000+ observations.</description>
      <pubDate>Tue, 26 May 2020 16:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650842#M31248</guid>
      <dc:creator>edwardar126</dc:creator>
      <dc:date>2020-05-26T16:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650843#M31249</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/330822"&gt;@edwardar126&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for the suggestion. I actually did this, but my concern being that since my dataset is 100,000+ I get a large list of patients and I would still need to group each individuals. I'm thinking about creating another variable for this step.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then, you have not yet described what you do want in enough detail to help.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 16:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650843#M31249</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-26T16:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650844#M31250</link>
      <description>Overall what I'm thinking about doing is creating a new variable that groups individuals by the number of times they received a certain service type. So in this case count the number of patients who received a service only once, twice, …, or 6+. The Proc Freq is definitely a good start to look at possible groupings, but I think what I will need to take a step further. Thanks again for your consideration, sorry for not being clear earlier I'm new to this sub &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 May 2020 17:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650844#M31250</guid>
      <dc:creator>edwardar126</dc:creator>
      <dc:date>2020-05-26T17:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by frequencies with more than one variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650847#M31252</link>
      <description>&lt;P&gt;Then you run PROC FREQ twice. The first time you use &lt;FONT face="courier new,courier"&gt;tables id*service/out=_a_ noprint;&lt;/FONT&gt; and save the results in a SAS data set. The second time you run PROC FREQ on data set _a_ with &lt;FONT face="courier new,courier"&gt;tables count;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 17:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Grouping-by-frequencies-with-more-than-one-variable/m-p/650847#M31252</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-26T17:31:42Z</dc:date>
    </item>
  </channel>
</rss>

