...And, just for grins, here's a PROC REPORT approach that creates an output dataset using just one pass through the data and the output dataset has ONLY the dates/names where the number of visits was GE 2 -and- the number of facilities was GE 2.
WORK.REPOUT is created by PROC REPORT -- which calculates the TOTVISIT column and the FACCNT column on the report -- so those 2 columns are available for WHERE processing. With TOTVISIT and FACCNT used in WHERE processing on the OUT= option, only the report rows that meet the WHERE condition will be written to the output dataset. Also on the OUT= option is the DROP= data set option to drop the automatic variable _BREAK_ and the RENAME= option to rename the absolute column numbers to be the facility values that they represent.
cynthia
[pre]
data test;
infile datalines;
input Date : mmddyy6. Name $ Facility $;
return;
datalines;
1/2/09 John A
1/2/09 Gary B
1/2/09 John B
1/4/09 Lisa C
1/4/09 Lisa C
1/5/09 Gary A
1/5/09 Mary D
1/6/09 Jess B
1/6/09 Jess D
1/6/09 Jess B
;
run;
ods listing close;
ods html file='report.html' style=sasweb;
proc report data=test nowd
out=repout(where=(totvisit ge 2 and faccnt ge 2)
rename=(_c3_=A _c4_=B _c5_=C _c6_=D)
drop=_break_);
title 'Report Approach';
column date name facility n=totvisit faccnt;
define date / group f=date9.;
define name /group;
define facility / across;
define totvisit / 'Total Visits';
define faccnt / computed "Facility Count";
** ACROSS variables have absolute numbers in PROC REPORT;
** so _c3_ = Facility A, _c4_ = Facility B,;
** _c5_ = Facility C, _c6_ = Facility D;
compute faccnt;
** use the N function to get the count of non-missing facility values;
** when count is 1, means they visited 1 facility, etc.;
** if there are more than 4 facilities, then logic needs to change;
faccnt=n(_c3_, _c4_, _c5_, _c6_);
endcomp;
run;
proc print data=work.repout;
title 'WORK.REPOUT is Output dataset from PROC REPORT';
format date date9.;
run;
ods html close;
[/pre]