Yes. You have to save all the labels from the original set in a temporary do-file and then run that after the reshape. Here's the entire code sequence from beginning to end:
Code:
ds ce_* cg_* local stublist `r(varlist)' local stublist: subinstr local stublist "ce_" "@", all local stublist: subinstr local stublist "cg_" "@", all local stublist: list uniq stublist foreach s of local stublist { local t = strtoname(substr(`"`s'"', 2, .)) local stublist: subinstr local stublist `"`s'"' `"@`t'"' } tempfile labeler label save _all using `labeler' reshape long `stublist', i(pidp) j(_j) string gen int date = cond(_j == "ce_", tm(2021m1), tm(2020m9)) format date %tmMonth_CCYY drop _j run `labeler'
Comment