How about something like this:
data r_mam;
length cow flag 8 ;
array sp_[5] $ 40;
infile datalines4 delimiter=';' missover;
input cow SP_1 SP_2 SP_3 SP_4 SP_5;
do i= 1 to dim(SP_);
SP_[i]=lowcase(SP_[i]);
flag=max(flag,(find(SP_[i],'staphylococcus') and not find(SP_[i],'aureus')));
put sp_[i]= flag=;
end;
drop i;
datalines4;
1;Streptoccous dysgalactiae;Klebsiella pneumoniae;Staphylococcus chromogenes
2;Staphylococcus aureus;Staphylococcus xylosus;Escherichia coli
3;Streptococcus uberis;Staphylococcus aureus
;;;;
run;
The result looks like this:
1 |
1 |
streptoccous dysgalactiae |
klebsiella pneumoniae |
staphylococcus chromogenes |
|
|
2 |
1 |
staphylococcus aureus |
staphylococcus xylosus |
escherichia coli |
|
|
3 |
0 |
streptococcus uberis |
staphylococcus aureus |
|
|
|