You could use the below macro to do this. It creates a list of macro variables from the variable doctor and loops through the PROC EXPORT statements. The value of doctor is resolved in both the WHERE= data set option as well as the OUTFILE=option.
You might also want to take a look at the ExcelXP tagset which allows you to generate multiple worksheets based on the by value as well. See the below for more information on this.
http://support.sas.com/rnd/base/topics/odsmarkup/
Ex1.
data one;
input DOCTOR $ PATIENT $;
cards;
Ann Mark
John Anton
Ann Jeff
Ann James
John Howard
William Cliff
;
run;
/* Create a list of macro variables */
proc sql noprint;
select count(distinct doctor) into :last
from one;
select distinct(doctor) into: val1- :val%left(&last)
from one;
run;
quit;
%macro loopit;
%do i=1 %to &last;
PROC EXPORT DATA=one(where=(doctor="&&val&i"))
OUTFILE="c:\data\&&val&i" DBMS=EXCEL2000 REPLACE;
run;
%end;
%mend;
%loopit
Ex2.
data one;
input DOCTOR $ PATIENT $;
cards;
Ann Mark
John Anton
Ann Jeff
Ann James
John Howard
William Cliff
;
run;
proc sort data=one;
by doctor;
run;
ods tagsets.excelxp file="temp.xls";
proc print data=one;
by doctor;
run;
ods tagsets.excelxp close;