<?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: Counting by two variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547458#M151708</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the suggestion! Would you also be able to suggest an option using a data step?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why don't first give it a go yourself and then ask questions accompanied by your code/log should you get stuck.&lt;/P&gt;
&lt;P&gt;A data step solution would require to first sort the data and then use if first.&amp;lt;variable&amp;gt;/last.&amp;lt;variable&amp;gt; and just summing up stuff in counter variables (which you retain and also set to 0 at the beginning of a new group).&lt;/P&gt;</description>
    <pubDate>Sun, 31 Mar 2019 00:25:03 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-03-31T00:25:03Z</dc:date>
    <item>
      <title>Counting by two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547371#M151680</link>
      <description>&lt;P&gt;Hello, I am working with a sample of health record data spanning a one-year period.&lt;/P&gt;&lt;P&gt;I need to know:&lt;/P&gt;&lt;P&gt;1) which providers were full-time, that is, the providers that had at least a total of 416 patient visits (i.e., encounters) in this sample of one year data (416 visits/year = 8 visits/week).&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) the average number of unique patient visits among all full-time providers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to conducting counting procedures in SAS, but I envision first creating a variable that includes the total number of unique patient visits for each full-time provider and then running a proc means to determine the average number among all full-time providers. I have provided an example of how my data set is organized below. Any help with this would be much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Patient_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;encounter_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;visit_provider&lt;/P&gt;&lt;P&gt;111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a&lt;/P&gt;&lt;P&gt;112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;134&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b&lt;/P&gt;&lt;P&gt;112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;145&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b&lt;/P&gt;&lt;P&gt;113&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;231&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c&lt;/P&gt;&lt;P&gt;114&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;223&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a&lt;/P&gt;&lt;P&gt;115&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;323&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d&lt;/P&gt;&lt;P&gt;116&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;443&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d&lt;/P&gt;&lt;P&gt;117&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;423&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 02:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547371#M151680</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-03-30T02:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Counting by two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547380#M151689</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here an option using SQL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm=' ' truncover;
  input Patient_id encounter_id visit_provider $;
  datalines;
111 123 a
112 134 b
112 145 b
113 231 c
114 223 a
115 323 d
116 443 d
117 423 b
;
run;

proc sql;
/*  create table want as*/
  select
      visit_provider,
      count(encounter_id) as n_encounters,
      count(encounter_id)/count(distinct patient_id) as avg_encounter_per_patient
  from have
  group by visit_provider
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Mar 2019 03:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547380#M151689</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-30T03:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Counting by two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547429#M151701</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the suggestion! Would you also be able to suggest an option using a data step?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 16:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547429#M151701</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-03-30T16:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Counting by two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547458#M151708</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the suggestion! Would you also be able to suggest an option using a data step?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why don't first give it a go yourself and then ask questions accompanied by your code/log should you get stuck.&lt;/P&gt;
&lt;P&gt;A data step solution would require to first sort the data and then use if first.&amp;lt;variable&amp;gt;/last.&amp;lt;variable&amp;gt; and just summing up stuff in counter variables (which you retain and also set to 0 at the beginning of a new group).&lt;/P&gt;</description>
      <pubDate>Sun, 31 Mar 2019 00:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-by-two-variables/m-p/547458#M151708</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-31T00:25:03Z</dc:date>
    </item>
  </channel>
</rss>

