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
SAS Super FREQ

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!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 1455 views
  • 3 likes
  • 5 in conversation