Hi julio,
When you perform statistics on the row again after masking some data, the masked data will not be involved and the results will change. You can see what I get with your script below:
Before recalculate:

After recalculate:

You can see that the results change.
If you need to recalculate the results after masking data, you can set the Recalculate Mode to Auto, and then no need to call the rowstats X-Function manually. To set to Auto, please use -r 1. For example:
// this way has no recalculation
rowstats -r 0 irng:=col(6)[1]:col($(nCols))[nRows] mean:=col(meanCtrl) sd:=col(sdCtrl);
// this way sets the Recalculate Mode to Auto
rowstats -r 1 irng:=col(6)[1]:col($(nCols))[nRows] mean:=col(meanCtrl) sd:=col(sdCtrl);
And then, you don't need to execute this line any more:
//perform definitive row stats for ctrls
rowstats -r 0 irng:=col(6)[1]:col($(nCols))[nRows] mean:=col(meanCtrl) sd:=col(sdCtrl);
See the results below:

By the way, in your script, there is a little mistake, which is two left curly braces "{" are missing because of the two lines are commented out.
//{type -c "row: " $(ii);
//{type -c "column: " $(jj);
Penn