Calculating Average Patients Seen Per Day

Date: January 2000

The following sample program will calculate the average number of patients seen per day for each physician on days where at least two patients where seen.

SAS Code

*THE FOLLOWING DATASET IS ASSUMED:
visits: records of physician visits made over a given period, usually a year;
*THE FOLLOWING VARIABLES ARE ASSUMED:
md_id: MD ID, identifies each individual physician
pat_id: Patient ID, identifies each individual patient
visdate: Visit date, the date when the visit occurred
*COUNT VISITS OF THE SAME PERSON TO THE SAME PHYSICIAN ON THE SAME DAY ONLY ONCE;
proc sort data=visits nodupkey;
by md_id visdate pat_id;
run;
*ADD UP TOTAL PATIENTS SEEN ON A GIVEN DAY;
data visdays;
set visits;
by md_id visdate pat_id;
retain pattot;
if first.visdate then pattot=0;
pattot=pattot+1;
if last.visdate and pattot>1 then output visdays;
*OUTPUT ONE RECORD FOR EVERY DAY EACH PHYSICIAN SAW AT LEAST 2 PATIENTS;
RUN;
*CALCULATE THE AVERAGE NUMBER OF PATIENT SEEN PER DAY FOR EACH PHYSICIAN;
proc summary data=visdays nway;
class md_id;
var pattot;
output out=avgpat mean=avgpat;
run;

©2003 Manitoba Centre for Health Policy (MCHP)