Editing in Batch Edit

Discussions about tabulating data in the designer or in batch mode
Forum rules
New release: CSPro 8.0
Post Reply
YFT_CBSD
Posts: 47
Joined: January 3rd, 2023, 12:36 am

Editing in Batch Edit

Post 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.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Editing in Batch Edit

Post 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;
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Editing in Batch Edit

Post 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
YFT_CBSD
Posts: 47
Joined: January 3rd, 2023, 12:36 am

Re: Editing in Batch Edit

Post by YFT_CBSD »

Hi, thanks for this.
Post Reply