Creating a multiple response based on the previous Multiple selected

Discussions about CSEntry
Post Reply
sham
Posts: 71
Joined: February 3rd, 2022, 7:30 pm

Creating a multiple response based on the previous Multiple selected

Post 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.
Gregory Martin
Posts: 1947
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

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

Post 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]);
sham
Posts: 71
Joined: February 3rd, 2022, 7:30 pm

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

Post 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.
You do not have the required permissions to view the files attached to this post.
sherrell
Posts: 407
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

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

Post by sherrell »

See attached Sham. I've adjusted the logic & added notes about what needed changing. Sherrell
You do not have the required permissions to view the files attached to this post.
sham
Posts: 71
Joined: February 3rd, 2022, 7:30 pm

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

Post by sham »

Waooo!!!,
It works so well.
Thank you sherrell .
I am most gratiful.
mardelhi1
Posts: 1
Joined: August 21st, 2025, 6:33 am

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

Post 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.
Arjun Brti
Posts: 63
Joined: October 15th, 2020, 3:40 am
Location: Nepal

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

Post by Arjun Brti »

Hi mardelhi1

Please look at the attached file dictonary and logic to create the level.
You do not have the required permissions to view the files attached to this post.
Post Reply