Filter a multiple response based on the previous not selected choices

Discussions about CSEntry
Post Reply
blumski
Posts: 37
Joined: May 7th, 2018, 7:02 am

Filter a multiple response based on the previous not selected choices

Post by blumski »

Hello community,

I'm trying to create multi select variable based on not selected choices of another multi select variable.

I read this viewtopic.php?t=5405 and tried to adapt the code as follows, but it did not work

Code: Select all

PROC Q2
preproc

valueset string vs1;
do numeric i=1 while i<=length(strip(Q1))
	if not ischecked(Q1[i:1], Q1) then
		vs1.add(getlabel(Q1, Q1[i:1]), Q1[i:1]);
	endif;
enddo;

setvalueset(Q2, vs1);
Would you please help me out ?
Arjun Brti
Posts: 49
Joined: October 15th, 2020, 3:40 am

Re: Filter a multiple response based on the previous not selected choices

Post by Arjun Brti »

I am using this code. try this.

PROC SecondQues
onfocus
valueset string selectMulti;
do numeric ctr = 1 while ctr <= FirstQues_VS1.length()
if not ischecked(FirstQues_VS1.codes(ctr), FirstQues) then
selectMulti.add(SecondQues_VS1.labels(ctr), SecondQues_VS1.codes(ctr));
endif;
enddo;
setvalueset(SecondQues, selectMulti);
Make sure the same value label in the both field. And convert the SecondQues's data capture field into Ckeckbox.
Last edited by Arjun Brti on October 5th, 2023, 11:33 pm, edited 1 time in total.
blumski
Posts: 37
Joined: May 7th, 2018, 7:02 am

Re: Filter a multiple response based on the previous not selected choices

Post by blumski »

Thanks Arjun Brti. It worked. Here's what I wrote :

Code: Select all

PROC C10_1
onfocus
valueset string VS;

do numeric ctr = 1 while ctr <= C9_VS1.length()
	if not ischecked(C9_VS1.codes(ctr), C9) then
		VS.add(C9_VS1.labels(ctr), C9_VS1.codes(ctr));
	endif;
enddo;

setvalueset($, VS);	
Post Reply