Page 1 of 1

Filter a multiple response based on the previous not selected choices

Posted: October 3rd, 2023, 8:13 pm
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 ?

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

Posted: October 4th, 2023, 6:21 am
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.

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

Posted: October 4th, 2023, 4:29 pm
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);