<?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: Compare to previous record and counts in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11246#M1271</link>
    <description>Wow! you guys rock!!! thank you so much for your help with this.</description>
    <pubDate>Thu, 17 Apr 2008 15:15:39 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-04-17T15:15:39Z</dc:date>
    <item>
      <title>Compare to previous record and counts</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11243#M1268</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 16:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11243#M1268</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-15T16:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Compare to previous record and counts</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11244#M1269</link>
      <description>You could use PROC SQL to build two tables that you could get your report from&lt;BR /&gt;
&lt;BR /&gt;
Sort of like this:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
CREATE TABLE PATIENT_CODE AS&lt;BR /&gt;
SELECT&lt;BR /&gt;
	PATIENT_ID,&lt;BR /&gt;
	PROBLEM_CODE,&lt;BR /&gt;
	COUNT(PATIENT_ID) AS TIMES&lt;BR /&gt;
FROM&lt;BR /&gt;
	PATIENT_TABLE&lt;BR /&gt;
GROUP BY&lt;BR /&gt;
	PATIENT_ID, PROBLEM_CODE;&lt;BR /&gt;
	&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
CREATE TABLE PROVIDER_CODE AS&lt;BR /&gt;
SELECT&lt;BR /&gt;
	PROVIDER,&lt;BR /&gt;
	PROBLEM_CODE,&lt;BR /&gt;
	COUNT(PROVIDER) AS TIMES&lt;BR /&gt;
FROM&lt;BR /&gt;
	PATIENT_TABLE&lt;BR /&gt;
GROUP BY&lt;BR /&gt;
	PROVIDER, PROBLEM_CODE&lt;BR /&gt;
ORDER BY &lt;BR /&gt;
	PROBLEM_CODE, TIMES DESC;	&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Hope that gets you started.&lt;BR /&gt;
&lt;BR /&gt;
Ike Eisenhauer</description>
      <pubDate>Tue, 15 Apr 2008 22:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11244#M1269</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-15T22:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Compare to previous record and counts</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11245#M1270</link>
      <description>Hi: &lt;BR /&gt;
  That's a nice solution. I was sort of thinking PROC TABULATE (or PROC REPORT) which would not require creating a table followed by a PROC PRINT, but would generate a report with the desired information. I did the Tabulate approach first, after creating some data (with a few extra rows):&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
data ptfile;&lt;BR /&gt;
  length problem_description $15;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input Patient_id Date : anydtdte9. Provider $ Problem_code Problem_description $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&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 Mark 210 Back_Pain&lt;BR /&gt;
101 07-Sep-07 Doe 210 Back_Pain&lt;BR /&gt;
101 08-Sep-07 Smith 210 Back_Pain&lt;BR /&gt;
101 09-Sep-07 Colby 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;
102 25-Jun-07 Doe 200 Arthritis&lt;BR /&gt;
102 26-Jun-07 Colby 200 Arthritis&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
ods listing close;&lt;BR /&gt;
ods html file='c:\temp\tab_method1.html' style=sasweb;&lt;BR /&gt;
   &lt;BR /&gt;
proc tabulate data=ptfile f=comma6.;&lt;BR /&gt;
  title '1a. Tabulate Approach -- One Big Table';&lt;BR /&gt;
  class patient_id provider problem_code;&lt;BR /&gt;
  table ((patient_id all='Patient Total') &lt;BR /&gt;
         (provider all='Provider Total')), &lt;BR /&gt;
          problem_code all='Total';&lt;BR /&gt;
  keylabel n = 'Count';&lt;BR /&gt;
  keyword all / style={vjust=b};&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
proc tabulate data=ptfile f=comma6.;&lt;BR /&gt;
  title '1b. Tabulate Approach -- Two Tables';&lt;BR /&gt;
  class patient_id provider problem_code;&lt;BR /&gt;
  table (patient_id all='Patient Total'), &lt;BR /&gt;
          problem_code all='Total';&lt;BR /&gt;
    &lt;BR /&gt;
  table ((provider all='Provider Total')), &lt;BR /&gt;
          problem_code all='Total';&lt;BR /&gt;
  keylabel n = 'Count';&lt;BR /&gt;
  keyword all / style={vjust=b};&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
if you run this, you will see that the 1a) output has the information one "big" table and the 1b) output has the information in two separate tables.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
here's the proc report approach using the same data, but with "list" output instead of cross-tab output and a summary line underneath every patient_id and every provider:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  &lt;BR /&gt;
ods html file='c:\temp\report_method4.html' style=sasweb;&lt;BR /&gt;
  &lt;BR /&gt;
** not an ACROSS example;&lt;BR /&gt;
proc report data=ptfile nowd&lt;BR /&gt;
  style(summary)=Header;&lt;BR /&gt;
  title '4a. Proc REPORT Approach -- Patient Table';&lt;BR /&gt;
  column patient_id problem_code n;&lt;BR /&gt;
  define patient_id / group;&lt;BR /&gt;
  define problem_code / group;&lt;BR /&gt;
  define n / 'Times' f=comma6.;&lt;BR /&gt;
  break after patient_id / summarize;&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
proc report data=ptfile nowd&lt;BR /&gt;
  style(summary)=Header;&lt;BR /&gt;
  title '4b. Proc REPORT Approach -- Provider Table';&lt;BR /&gt;
  column provider problem_code n ;&lt;BR /&gt;
  define provider / group;&lt;BR /&gt;
  define problem_code / group;&lt;BR /&gt;
  define n / 'Times' f=comma6.;&lt;BR /&gt;
  break after provider / summarize;&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 16 Apr 2008 00:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11245#M1270</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-04-16T00:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Compare to previous record and counts</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11246#M1271</link>
      <description>Wow! you guys rock!!! thank you so much for your help with this.</description>
      <pubDate>Thu, 17 Apr 2008 15:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Compare-to-previous-record-and-counts/m-p/11246#M1271</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-17T15:15:39Z</dc:date>
    </item>
  </channel>
</rss>

