This one is a tad tricky, because the 1s and 2's also occur in the _2011 suffix, as well as in the infixed position where you want to isolate them. But it can be done as follows:
Presumably the 1, 2, 3, 4 represent something like year, or wave, or something like that, so you might want to pick a more informative name for that variable than _j. But as I didn't know what it is, I just went generic.
Code:
ds w1_* local stubs `r(varlist)' local stubs: subinstr local stubs "1_" "@_", all display `"`stubs'"' reshape long `stubs', i(pid) j(_j)
Comment