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'
usubjid | ieorres_incl01 | ieorres_incl02 | ieorres_incl03 | ieorres_incl04 | ieorres_incl05 | ieorres_incl06 | ieorres_incl07 | ieorres_incl08 | ieorres_incl09 | Inclusion |
1001 | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
1002 | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
1003 | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
1004 | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
1005 | yes | yes | yes | yes | yes | yes | yes | yes | yes |
data want;
set have;
array t(*) ieorres_incl01-ieorres_incl09;
length Inclusion $3;
if 'NO' in t then Inclusion='NO';
else Inclusion='YES';
run;
No loop needed. Use the WHICHC function.
Example at that link.
data want;
set have;
array t(*) ieorres_incl01-ieorres_incl09;
length Inclusion $3;
if 'NO' in t then Inclusion='NO';
else Inclusion='YES';
run;
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 ID | Consent Obtained | Inclusion Met | Exclusion Not Met | Dose Volume Compliance | Correct Vial Received | Dosing Window | Sample Obtained | Flagged |
1001 | Yes | Yes | Yes | Yes | Yes | Yes | Yes | |
1002 | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
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;
@novinosrin it just worked pergect!
Thank you SO VERY MUCH!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.