Is there a way to iterate through elements of the local created by levelsof and remove those elements? I found one way to do this with a macro consisting of numbers (https://www.stata.com/statalist/arch.../msg01052.html):

Code:
local alpha 1 2 3 4 5
di "`alpha'"
local not 1
local alpha: list alpha- not
di "`alpha'"
but when I try it with levelsof, I'm getting an "invalid name" error. Here are the displays I see:

`"10151_1A"' `"10151_1B"' `"10641_1"' (after running the levelsof command)
10151_1A10151_1B10641_1 (when displaying levels_nonmissing the first time)
`10151_1A"' `"10151_1B"' `"10641_1"'" (when displaying it the second time)

It looks like the quote at the beginning of the local was moved to the end. My code is below:

Code:
pause on
levelsof id, local(levels)
levelsof id, local(levels_nonmissing)
di `levels_nonmissing'
foreach unt of local levels {
    local not "`unt'"
    local levels_nonmissing: list levels_nonmissing - not
    di "`levels_nonmissing'"
    pause
}
For context, I am attempting to follow Andrew's method here:

https://www.statalist.org/forums/for...a-new-variable

to iterate through subsets of my data, run regressions, store their coefficients, and label my coefficient columns. Some of my regressions don't work, so I'm using capture and a conditional statement to try to remove those names from the local macro so that I can name the non-missing regressions correctly (skipping the missing id names).

Thanks!