0

I have a dataset (patients) as such:

Pat_ID     Hos     Date

A              11        1/1/2012

B              12         2/3/2012

B              13         2/3/2012

C              11         4/1/2012

C               11         4/5/2012

How do I count using proc sql such that the outcome looks something like this:

Pat_ID      Visits

A                 1

B                 1

C                 2

Since B has two visits on the same date, they are considered as only 1 visit, whereas C has 2 visits because they are on different dates.

PinkyL
  • 341
  • 1
  • 8
  • 19

1 Answers1

1
select Pat_ID, count(distinct VisitDate) as Visits
from patient
group by Pat_ID
order by Pat_ID asc
fukanchik
  • 2,811
  • 24
  • 29
  • An answer containing only code is not a high quality answer; please explain the method by which you solve the problem (what concepts or methods are useful to understand in solving the problem). Teach a man to fish, don't just give him fish. – Joe Apr 02 '15 at 19:49