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!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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