Hi Gregory
I am having many multiple response questions i am using following syntax to check the multiple responses in multiple occurrence field.
i = 0;
do while i < 99
if count ($ where $ in i) > 1 then
errmsg("Duplicate value");
reenter;
endif;
i = i + 1;
enddo;
Instead of this if you can give me any function which i can use easily.
Thanks
Bharadwaj
Function to check duplicate values in multiple response vari
Re: Function to check duplicate values in multiple response
Do this work for you?
Code: Select all
do i = 1 while i < curocc()
if $(i) = $ then
errmsg("Value %d already in position # %d",$,i);
reenter;
endif;
enddo;
Re: Function to check duplicate values in multiple response
I think this code must be enough and this works only in data entry
proc MULT_FIELD
intActualValue=$;
if count(MULT_FIELD where MULT_FIELD=intActualValue) then
errmsg("This value has been entered");
reenter;
endif;
proc MULT_FIELD
intActualValue=$;
if count(MULT_FIELD where MULT_FIELD=intActualValue) then
errmsg("This value has been entered");
reenter;
endif;
Hannes Rodriguez
Lima, Perú
Lima, Perú
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Function to check duplicate values in multiple response
lls and hannesrr both present reasonable ways to check to see if a value is duplicated in a repeating item. There is no CSPro function that can automatically return to you whether or not there was a duplicate across the items.
You could use hannesrr's code but you would have to change the code to say count(...) > 1. Count will always return 1 because there will always be at least one instance of the value (i.e., the just-entered value!).
You could also write:
You could use hannesrr's code but you would have to change the code to say count(...) > 1. Count will always return 1 because there will always be at least one instance of the value (i.e., the just-entered value!).
You could also write:
proc MULT_FIELD
intActualValue = $;
if seek(MULT_FIELD = intActualValue) < curocc() then
errmsg("This value has been entered");
reenter;
endif;
intActualValue = $;
if seek(MULT_FIELD = intActualValue) < curocc() then
errmsg("This value has been entered");
reenter;
endif;