I would like to do infinity loop like in JAVA
for(i=1;i<200;I++){
if (COL(i) != COL1 AND COL(i) != " ") {
q_person_type = "Multiple";
}
else {
q_person_type = COL1
}
}
For SAS Code
data test3(keep=q_full_nm q_person_type rename=(q_full_nm=node_tooltip));
set test2;
do i = 1 to n by 1;
q_person_type=COL1;
if COLi ne ' ' AND COLi ne COL1 then q_person_type="Multiple";
run;
I cannot run this code, could you please check it which part i'm wrong
what i want is if COL2, COL3 ... until COL N is not equal to COL1 return "Multiple" but if COL2, COL3 .... until COL N is equal to COL1 or is " " return COL1
Please see picture for more understanding
Hi,
You can use arrays to loop over data, example below. Please note this code is not tested. If you want working code, please post test data - in the form of a datastep, which reflects your actual data - and what you want the output to look like.
data want; set have; array col{3}; result="Pass"; do i=2 to 3; if col{i} ne col{1} then result="Fail"; end; run;
I looked at the picture of your data and wrote this. Perhaps with this and if you provide and explanation of what you need someone will be able to help.
data col;
infile cards missover;
input id:$3. (col1-col3)(:$2.);
cards;
001 TP
002 TP
003 RP
004 TP
005 TP
006 RP TP
007 RP
008 RP TP
009 RP
010 RP
011 TP RP RP
;;;;
run;
proc print;
run;
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.