<?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 Compare to previous record and counts in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Compare-to-previous-record-and-counts/m-p/11145#M2295</link>
    <description>I need to create a report that will show a count of how many times a patient was seen for the same problem_code, and then find out the providers who saw the most patients with the same problem_codes.&lt;BR /&gt;
&lt;BR /&gt;
I am able to do a count by Patient_id, but this does not help me. Could you please help???&lt;BR /&gt;
&lt;BR /&gt;
Patient_id Date Provider Problem_code Problem_description&lt;BR /&gt;
100 01-Jan-07 Smith 200 Arthritis&lt;BR /&gt;
100 04-Apr-07 Doe 300 Joint_Pain&lt;BR /&gt;
100 30-Jun-07 Colby 200 Arthritis&lt;BR /&gt;
101 14-Feb-07 Doe 210 Back_Pain&lt;BR /&gt;
101 07-Sep-07 Doe 210 Back_Pain&lt;BR /&gt;
102 16-Jun-07 Mark 214 Headache &lt;BR /&gt;
102 24-Jun-07 Smith 200 Arthritis&lt;BR /&gt;
....</description>
    <pubDate>Tue, 15 Apr 2008 15:50:19 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-04-15T15:50:19Z</dc:date>
    <item>
      <title>Compare to previous record and counts</title>
      <link>https://communities.sas.com/t5/Developers/Compare-to-previous-record-and-counts/m-p/11145#M2295</link>
      <description>I need to create a report that will show a count of how many times a patient was seen for the same problem_code, and then find out the providers who saw the most patients with the same problem_codes.&lt;BR /&gt;
&lt;BR /&gt;
I am able to do a count by Patient_id, but this does not help me. Could you please help???&lt;BR /&gt;
&lt;BR /&gt;
Patient_id Date Provider Problem_code Problem_description&lt;BR /&gt;
100 01-Jan-07 Smith 200 Arthritis&lt;BR /&gt;
100 04-Apr-07 Doe 300 Joint_Pain&lt;BR /&gt;
100 30-Jun-07 Colby 200 Arthritis&lt;BR /&gt;
101 14-Feb-07 Doe 210 Back_Pain&lt;BR /&gt;
101 07-Sep-07 Doe 210 Back_Pain&lt;BR /&gt;
102 16-Jun-07 Mark 214 Headache &lt;BR /&gt;
102 24-Jun-07 Smith 200 Arthritis&lt;BR /&gt;
....</description>
      <pubDate>Tue, 15 Apr 2008 15:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Compare-to-previous-record-and-counts/m-p/11145#M2295</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-15T15:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Compare to previous record and counts</title>
      <link>https://communities.sas.com/t5/Developers/Compare-to-previous-record-and-counts/m-p/11146#M2296</link>
      <description>Hi Nathalie.&lt;BR /&gt;
By the way, I don't think you're posting in the right forum. That would rather be a question for the SAS PROCEDURES category.&lt;BR /&gt;
Anyway, you can easily solve your problem with a little bit of SQL, which allows you to count, group, order, compute new variables all a the same time.&lt;BR /&gt;
[pre]&lt;BR /&gt;
DATA test ;&lt;BR /&gt;
	INPUT Patient_id $ Date anydtdte. Provider $ Problem_code $ Problem_description :$20. ;&lt;BR /&gt;
	FORMAT date DDMMYY10. ;&lt;BR /&gt;
CARDS ;&lt;BR /&gt;
100 01-Jan-07 Smith 200 Arthritis&lt;BR /&gt;
100 04-Apr-07 Doe 300 Joint_Pain&lt;BR /&gt;
100 30-Jun-07 Colby 200 Arthritis&lt;BR /&gt;
101 14-Feb-07 Doe 210 Back_Pain&lt;BR /&gt;
101 07-Sep-07 Doe 210 Back_Pain&lt;BR /&gt;
102 16-Jun-07 Mark 214 Headache &lt;BR /&gt;
102 24-Jun-07 Smith 200 Arthritis&lt;BR /&gt;
;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC SQL ;&lt;BR /&gt;
	SELECT patient_id, problem_code, problem_description, count(*) AS number LABEL="# of times"&lt;BR /&gt;
	FROM test&lt;BR /&gt;
	GROUP BY patient_id, problem_code, problem_description&lt;BR /&gt;
	ORDER BY number DESC&lt;BR /&gt;
	;&lt;BR /&gt;
	SELECT provider, &lt;BR /&gt;
		   COUNT(*) AS totn LABEL="Total # of visits",&lt;BR /&gt;
		   COUNT(DISTINCT patient_id!!problem_code) AS problemsN LABEL="The # of distinct problems on distinct patients",&lt;BR /&gt;
		   CALCULATED totn - CALCULATED problemsN AS reRuns LABEL="The # of visits for already seen combination of patients and problems"&lt;BR /&gt;
	FROM test&lt;BR /&gt;
	GROUP BY provider&lt;BR /&gt;
	ORDER BY reRuns DESC&lt;BR /&gt;
	;&lt;BR /&gt;
QUIT ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Wed, 23 Apr 2008 10:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Compare-to-previous-record-and-counts/m-p/11146#M2296</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-04-23T10:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Compare to previous record and counts</title>
      <link>https://communities.sas.com/t5/Developers/Compare-to-previous-record-and-counts/m-p/11147#M2297</link>
      <description>Thank you for your response. Very much appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 24 Apr 2008 20:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Compare-to-previous-record-and-counts/m-p/11147#M2297</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-24T20:22:33Z</dc:date>
    </item>
  </channel>
</rss>

