I think it may be a good idea to check for unexpected values/errors.
Given data like this
data have;
input person $ result $;
datalines;
Person1 Positive
Person1 Positive
Person2 Unknown
Person2 Positive
Person3 Unknown
Person3 Missing
Person4 Gylle
;run;
(note that I put in a not predicted value "Gylle" in the last row)
One way to go about it could be this:
data want;
array values(3) $8 _temporary_ ('Positive','Unknown','Missing');
do until(last.person);
set have;
by person;
_idx=min(_idx,whichc(result,of values(*)));
if _idx=0 then
error 'Unexpected result value: ' result;
end;
if _idx>0 then
result=values(_idx);
else
delete;
drop _idx;
run;
... View more