Page 1 of 1

Check string var

Posted: February 15th, 2022, 12:47 am
by Arjun Brti
Dear team;

I faced to write a skip logic in my application. My problem is:

for example: Q1 is string variable with multiple responses ABCDE, Q2 is string variable with multiple responses ABCDE and Q3 is string variable with multiple responses ABCDE. Now I have Q4 variable with single response and numeric variable. Now I want to ask the Q4 variable if Q1 = ABC or Q2 = ABC or Q3 = ABC otherwise I want to skip to Q8. Seeking for your advice.

Thank you.

Best
Brti

Re: Check string var

Posted: February 16th, 2022, 11:11 am
by sherrell
>Now I want to ask the Q4 variable if Q1 = ABC or Q2 = ABC or Q3 = ABC otherwise I want to skip to Q8.

if you didn't have the skip, I would have written:

Code: Select all

PROC Q4
preproc
  ask if Q1 in 'A','B','C' or Q2 in 'A','B','C' or Q3 in 'A','B','C';
but since you have the skip, I'd make it:

Code: Select all

PROC Q4
preproc
  if Q1 in 'A','B','C' or Q2 in 'A','B','C' or Q3 in 'A','B','C' then
  // nop, stay put
  else
    skip to Q8;
  endif;
Be sure to set the field properties for Q1-Q3 to uppercase, for otherwise you'll have people entering lowercase letters and your logic will fail (or allow lowercase letters as well, but I find that sloppy/inconsistent).

Sherrell