BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Annie_Fréchette
Obsidian | Level 7

Good point!

In your first line SNA=1, and I have another binary variable S.aureus=1

In your second line SNA also=1, it's a binary variable, not a sum.

 

Annie

SASJedi
Ammonite | Level 13

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:

Obs cow flag sp_1 sp_2 sp_3 sp_4 sp_5
1 1 1 streptoccous dysgalactiae klebsiella pneumoniae staphylococcus chromogenes    
2 2 1 staphylococcus aureus staphylococcus xylosus escherichia coli    
3 3 0 streptococcus uberis staphylococcus aureus      
Check out my Jedi SAS Tricks for SAS Users
Annie_Fréchette
Obsidian | Level 7

Thanks! This has resolved my exceptions!

 

Have a nice day!