Page 1 of 1

Creating a multiple response based on the previous Multiple selected

Posted: April 6th, 2023, 5:26 am
by sham
Hi Family,
This time round, I have a variable(Q1) with multiple selection and want to create another variable(Q2) but which should contain only the once that were selected in Q1. what do I do?

Q1(Select multiple)
A. YAM
B. Cassava...............selected
C. Maize,.................selected
D.. Millet
E. NONE
So I want in Q2 to have a preloaded options for those that were selected in Q1
I tried all the magic and went through documentation but still not getting it.
Q2(Multiple select)
A. Cassava
B. Maize

This is the logic that I used but did not succeed
Q2
preproc
valueset string vs1 = Q1_VS1;
do numeric i=1 while i<=length(Q1)
vs1.add(Q1[i:1]);
enddo;
setvalueset(Q2, vs1);


ERROR(6): Invalid function call (comma expected)


I will appreciate your support family.

Re: Creating a multiple response based on the previous Multiple selected

Posted: April 6th, 2023, 7:38 am
by Gregory Martin
In this line:
vs1.add(Q1[i:1]);
The ValueSet.add function requires at least two arguments, the label and the code: https://www.csprousers.org/help/CSPro/v ... ction.html

You're only passing the code. Try this:
vs1.add(getlabel(Q1, Q1[i:1]), Q1[i:1]);

Re: Creating a multiple response based on the previous Multiple selected

Posted: April 6th, 2023, 10:32 am
by sham
Hi Martin,
Thank you soo much for your swift guide.
Below is my updated logic reference to your guide.

Q2
preproc
valueset string vs1 = Q1_VS1;
do numeric i=1 while i<=length(Q1)
s1.add(getlabel(Q1, Q1[i:1]), Q1[i:1]);
enddo;
setvalueset(Q2, vs1);

But the logic is silent. I read the attach link but still do not get it.
Kindly find the attach setup for more clarity.

I really appreciate your support.

Re: Creating a multiple response based on the previous Multiple selected

Posted: April 6th, 2023, 5:40 pm
by sherrell
See attached Sham. I've adjusted the logic & added notes about what needed changing. Sherrell

Re: Creating a multiple response based on the previous Multiple selected

Posted: April 6th, 2023, 8:09 pm
by sham
Waooo!!!,
It works so well.
Thank you sherrell .
I am most gratiful.

Re: Creating a multiple response based on the previous Multiple selected

Posted: September 1st, 2025, 5:52 am
by mardelhi1
Hi,

I'v two question.

1st response is
1-Delhi
2-Noida
3-Gurugram

2nd response is
1-Lajpat Nagar
2-New Delhi
3-Sector 15 Noida
4-Sector 18 Noida
5-Sector 15 Gurugram
6-Sector 18 Gurugram


if i select "Delhi" in 1st question then 2nd question desplay on "Lajpat Nagar and New Delhi" Only
if i select "Noida" in 1st question then 2nd question desplay on "Sector 15 Noida and Sector 18 Noida" Only
if i select "Gurugram" in 1st question then 2nd question desplay on "Sector 15 Gurugram and Sector 18 Gurugram" Only

please suggest me for this type of filter.

Re: Creating a multiple response based on the previous Multiple selected

Posted: September 8th, 2025, 12:47 am
by Arjun Brti
Hi mardelhi1

Please look at the attached file dictonary and logic to create the level.