BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zimcom
Pyrite | Level 9

 

Hi Community,

 

I want to do a while loop to scan the variables 01 - 09 and if all of them is 'yes' then the last column will be populated as 'yes', otherwise if ther eis one 'no' then the last column will be populated as 'no'

usubjidieorres_incl01ieorres_incl02ieorres_incl03ieorres_incl04ieorres_incl05ieorres_incl06ieorres_incl07ieorres_incl08ieorres_incl09Inclusion
1001yesyesyesyesyesyesyesyesyes 
1002yesyesyesyesyesyesyesyesyes 
1003yesyesyesyesyesyesyesyesyes 
1004yesyesyesyesyesyesyesyesyes 
1005yesyesyesyesyesyesyesyesyes 
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data want;
set have;
array t(*) ieorres_incl01-ieorres_incl09;
length Inclusion $3;
if 'NO' in t then Inclusion='NO';
else Inclusion='YES';
run;

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

No loop needed. Use the WHICHC function.

https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=lefunctionsref&docsetTarget=p...

 

Example at that link.

 

 

--
Paige Miller
zimcom
Pyrite | Level 9

@PaigeMiller @novinosrin 

All roads lead to Rome!

Power of SAS, thank you both!

novinosrin
Tourmaline | Level 20
data want;
set have;
array t(*) ieorres_incl01-ieorres_incl09;
length Inclusion $3;
if 'NO' in t then Inclusion='NO';
else Inclusion='YES';
run;
zimcom
Pyrite | Level 9

@novinosrin 

 

I have a new situation where I need to the same to populate "Yes"/"No" in the last column based on the Yes/No from the previous column as above, but the variable names are quite random and how can I define trhe array in this case

array t(*) ieorres_incl01-ieorres_incl09;

Thank you!

 

Subject IDConsent
Obtained
Inclusion
Met
Exclusion
Not Met
Dose
Volume
Compliance
Correct
Vial
Received
Dosing
Window
Sample
Obtained
Flagged
1001YesYesYesYesYesYesYes 
1002YesYesYesYesYesYesYes 
novinosrin
Tourmaline | Level 20

How about using double dash var list as long as they follow the order that your sample suggests from left to right

array t(*) ConsentObtained--sampleObtained;

 

zimcom
Pyrite | Level 9

@novinosrin it just worked pergect!

Thank you SO VERY MUCH!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1846 views
  • 2 likes
  • 3 in conversation