Creating a multiple response based on the previous Multiple selected

Discussions about CSEntry
Post Reply
sham
Posts: 69
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: 1796
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: 69
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.
Attachments
mresponse.zip
(58.05 KiB) Downloaded 84 times
sherrell
Posts: 397
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
Attachments
Mresponse (smg).zip
(3.07 KiB) Downloaded 115 times
sham
Posts: 69
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.
Post Reply