Here's one approach that's simpler. It matches the 11.1% you reported via your method.
proc freq data=test noprint;;
where date='05Nov2018'd;
table person / out=t1;
run;
proc format;
value dup_fmt
1 = 'Unique'
2-high = 'Duplicated';
run;
proc freq data=t1 (rename=count=Freq) noprint;;
table freq / out=t2;
format freq dup_fmt.;
run;
@DME790 wrote:
Have added the following code that gets me the same day repeat Persons.
data test2;
set test;
Where date = '05Nov2018'd;
run;
proc sql;
Create table testCallPersons as
Select Date, Person, count(person) as personcount
From (select distinct date, Person from Test2)
Group by Date, Person;
quit;
proc Summary data=testCallPersons;
By Date;
VAr personcount;
Output out=testPCount (Drop=_freq_ _Type_) sum=;
run;
proc sql;
Create table testCallCount as
Select Date, Person, count(person) as Callcount
From (select date, Person from Test2)
Group by Date, Person;
quit;
Data TestDupPerscount;
Set testCallCount;
If Callcount >1 Then
DupCount = 2;
Else DupCount = 1;
run;
proc Summary data=TestDupPerscount;
By Date;
VAr Callcount DupCount;
Output out=testCCount (Drop=_freq_ _Type_) sum=;
run;
Data testMerge;
Merge testPCount testCCount;
By Date;
run;
Data testPerc;
Drop personcount Callcount DupCount;
Set testmerge;
Day1Perc = (DupCount - personcount) / personcount;
format Day1perc percent7.2;
run;
Anyway of doing this smarter? Just now need to work out how to match against the previous days to get the duplicates.
Cheers
Dean
... View more