Check string var

Discussions about CSEntry
Post Reply
Arjun Brti
Posts: 63
Joined: October 15th, 2020, 3:40 am
Location: Nepal

Check string var

Post 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
sherrell
Posts: 407
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Check string var

Post 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
Post Reply