Slightly to my surprise, I think I've found a bug in SET_2DA_ENTRY.
Reproduction: take the BG2EE 'wish.2da' file. It's a standard 2da:
2DA V1.0
*
1 2 3 4
1 23 23 23 22
2 24 24 24 24
3 25 10 25 30
4 26 26 33 26
...
Say we want to change the last column header from '4' to '-1'. (There's no earthly reason to do this, it's just to demonstrate the bug). You'd expect this to work:
SET_2DA_ENTRY 0 3 4 "-1"
But if you do that, it actually changes the penultimate column header:
2DA V1.0
*
1 2 -1 4
1 23 23 23 22
2 24 24 24 24
3 25 10 25 30
4 26 26 33 26
...
FWIW, the same bug occurs if you run
SET_2DA_ENTRY 2 3 0 "-1"