I don't know how Stata decides whether there are column names in the text file, but my guess would be that it bases it on whether there is a value in the first row for at least the number of subsequent columns. If you had created 10 imputed data sets then this would correspond with the value of 10 that you are seeing.
The 'in' is just referring to the row number of the chosen variable so:
- Code: Select all
local varname = v22 in 1
is setting the local macro varname
to the value of row 1in the variable v22
It looks like the code is looping until it gets a blank variable name, which you won't get if you have more variable names than imputed data sets. A possible fix would be to add an extra tab to the end of the first line of impvals.txt so that this condition is met.