Hi Statalist,

Please consider the following sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(evntr310 evntr312 evntr313 evntr346 evntr347 evntr314) float(response_resr3301_3 response_resr3110_3 response_resr3210_3 response_resr3310_3 response_resr3112_3 response_resr3113_3 response_resr3146_3 response_resr3147_3)
. . . . . . . . . . . . . .
0 0 0 . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 . . . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 0 0 . 1 . 0 0 0 0 0 0 0 1
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 . . . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 0 0 . 1 0 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 . . . 0 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
0 0 0 . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 0 0 . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 0 . . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 . . . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 0 0 . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
0 0 0 . 1 . 0 0 0 0 0 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
end
label values evntr310 evntr310
label def evntr310 0 "no", modify
label values evntr312 evntr312
label def evntr312 0 "no", modify
label values evntr313 evntr313
label def evntr313 0 "no", modify
label values evntr346 evntr346
label values evntr347 evntr347
label def evntr347 0 "no", modify
label def evntr347 1 "yes", modify
label values evntr314 evntr314
label def evntr314 0 "no", modify
My original data contained several more variables and I kept only a few for this sample data. Hopefully the loop and the associated error code that I'm getting in the full data would be replicated here
I'm trying the following loop:
Code:
forvalues i=0/4{
forvalues j=1/9{
replace response_resr31`i'`j'_3=. if evntr3`i'`j'==0
}
}
.
But not all `i'x`j' combination is present in the data and hence the loop is terminating:
Code:
variable response_resr3101_3 not found
r(111);
Can anyone please suggest how I should go about it so that I'm able to run the loop through all available variables without the loop terminating midway? I did go through the statalist archive for similar queries however, could not exactly understand the solutions given hence I'm asking here. Apologies if the question seems too repetitive.

Thanks,
Titir