0

I have a dataset as such:

    Pat_ID  Date        Prov_ID
    A       05/12/2012  X1
    A       05/12/2012  X2
    B       11/12/2012  X1
    B       03/22/2012  X1
    C       04/25/2012  X1
    C       04/25/2012  X2
    C       04/25/2012  X3
    ...

As can be seen, some patients have the same date but different providers and some have diff dates but the same provider. How can I use proc sql to count by Pat_ID and Date such that it would give something like this:

Pat_ID  Date       Count
A       05/12/2012 2
B       11/12/2012 1
B       03/22/2012 1
C       04/25/2012 3
PinkyL
  • 341
  • 1
  • 8
  • 19

2 Answers2

1

Try this:

select Pat_ID, Date, count( Prov_ID ) as Count from ReplaceThisWithYourTablesName group by Pat_ID, Date order by Pat_ID asc, Date desc

You didn't specify the table name so you'll have to fix that yourself.

Important part is to list both columns in the group by in the order of most importance.

serverSentinel
  • 994
  • 6
  • 20
1
SELECT Pat_ID, Date, COUNT(Prov_ID)
FROM your_table
GROUP BY Pat_ID, Date
axblount
  • 2,639
  • 23
  • 27