Page 1 of 1

Editing in Batch Edit

Posted: April 6th, 2023, 7:19 am
by YFT_CBSD
Hi can anyone help me with my code

item Apple
len = 6
Apple has valuesets from A to E

Value of Apple = AHBZC

do numeric i = 1 while i<=6
if !Apple[i:1] in valuesets then
impute(Apple,); /// How can i remove the answers that is not in the valuesets? i want the output to be "ABC"
endif;
enddo;

Thanks.

Re: Editing in Batch Edit

Posted: April 6th, 2023, 7:45 am
by Gregory Martin
Try this:
do numeric ctr = length(strip(APPLE)) while ctr > 0 by -1
   
if not invalueset(APPLE[ctr:1], APPLE_VS1) then
       
APPLE = APPLE[1:(ctr - 1)] + APPLE[ctr + 1];
    endif;
enddo;

Re: Editing in Batch Edit

Posted: April 6th, 2023, 1:46 pm
by sherrell
I'm not sure if you used CSPro to collect the data, but if so, you should be restricting the allowable responses by defining a value set for the question. During entry you should utilize the isChecked() function, as it will not allow out-of-range values to be entered.

https://www.csprousers.org/help/CSPro/i ... ction.html

Sherrell

Re: Editing in Batch Edit

Posted: April 10th, 2023, 10:26 pm
by YFT_CBSD
Hi, thanks for this.