Hello,
I have a dataset (first example below) that I reshape from wide to long. However I lost of the label information. How can I keep the labels of the variables? I send below the example of the data and the command that I used to reshape the data. Thank you in advance.




Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input long(pidp psu) int strata long(i_hidp j_hidp k_hidp) byte(cg_semp ce_semp ce_parent0plus ce_couple cg_couple)
   76165   19    6 141657616 141460418 141045620 -8  1 1 1 1
  280165   67   15 754793216 754371618 754113220  . -8 2 1 .
  469205  106   25 415059096 414738818 414412420  . -8 1 2 .
  732365  157   43 619371216 618949618 618698020 -8 -8 2 2 2
 1587125  215   65 618269616 617895618 617671220 -8  3 2 2 2
 4849085  560  148 347554816 347255618 346990420 -8  1 2 1 1
68002725    1    1  73025216  72739618  72420020 -8  4 2 2 2
68008847 2012 2006  68040816  68040818  68027220 -8  1 2 2 2
68010887 2012 2006  68054416  68054418  68040820 -8  1 2 1 1
68029931 2060 2030  68136016  68129218  68102020 -8  . . . 1
68031967 2060 2030  68142816  68136018  68108820  4  4 2 2 2
68035365   11    4  73045616  72760018  72433620 -8  4 2 2 2
68035367 2060 2030  68156416  68149618  68115620 -8  1 1 1 1
68041487 2084 2042  68176816  68170018  68142820 -8  1 2 1 1
68041491 2084 2042  68176816  68170018  68142820 -8  . . . 1
68045567 2084 2042  68210816  68204018  68177500 -8  1 2 2 2
68051007 2108 2054  68251616  68244818  68204020 -8  2 2 1 1
68051011 2108 2054  68251616  68244818  68204020 -8  1 2 1 1
68058487 2108 2054  68272016  68265218  68224420 -8  4 2 1 1
68058491 2108 2054  68272016  68265218  68224420 -8  4 2 1 1
68060531 2108 2054  68285616  68278818  68238020 -8  1 2 1 1
68060533   18    6  73059216  72773618        -9 -8  4 2 1 1
68060537   18    6  73059216  72773618        -9 -8  4 2 1 1
68061288 2012 2006  68047616  68047618  68034020  . -8 1 1 .
68063247 2132 2066  68292416  68285618  68244820 -8  1 2 1 1
68063927 2132 2066  68299216  68292418  68251620 -8  1 2 1 1
68063931 2132 2066  68299216  68292418  68251620 -8 -8 2 1 1
68064605   18    6  73066016  72780418  72454020 -8  4 2 1 1
68064609   18    6  73066016  72780418  72454020 -8  4 2 1 1
68068007 2132 2066  68326416  68312818  68272020 -8  1 2 1 1
68068011 2132 2066  68326416  68312818  68272020  .  1 2 2 .
68068082 2012 2006  68054416  68054418  68040820 -8  2 2 1 1
68097245   25    8  73072816  72787218  72460820 -8  4 2 2 2
68097927 2180 2090  68421616  68414818  68353620 -8  4 2 2 2
68112211 2228 2114  68462416  68448818  68380820  .  1 1 1 .
68120367 2228 2114  68476016  68462418  68394420 -8  4 2 2 2
68120375 2228 2114  68476696  68469218  68401220 -8  1 1 2 2
68125127 2252 2126  68516816  68503218  68428420 -8  1 2 1 1
68125131 2252 2126  68516816  68503218  68428420 -8  1 2 1 1
68125135 2252 2126  68516816  68503218  68428420 -8  1 2 2 2
68133285   34   11  73086416  72800818  72474420 -8  4 2 2 2
68133289   34   11  73093216  72807618  72481220 -8  4 1 1 1
68136009   34   11  73106816  72821218  72494820 -8  1 2 2 2
68137365   34   11  73113616  72828018  72501620 -8 -8 2 2 2
68138045   34   11  73120416  72834818  72508420 -8  4 2 1 1
68138049   34   11  73120416  72834818  72508420 -8  4 2 1 1
68138051 2276 2138  68550816  68544018  68469220 -8  4 2 1 1
68144847 2276 2138  68584816  68578018  68503220 -8  1 2 1 1
68144851 2276 2138  68584816  68578018  68503220 -8  1 2 1 1
68148247 2300 2150  68591616  68584818  68510020 -8 -8 2 1 1
68148251 2300 2150  68591616  68584818  68510020  .  4 2 1 .
68150967 2300 2150  68598416  68591618  68516820  .  1 2 1 .
68150971 2300 2150  68598416  68591618  68516820 -8  1 2 1 1
68150975 2300 2150  68598416  68591618  68516820 -8  1 2 2 2
68155047 2300 2150  68618816  68605218  68530420  4 -8 2 1 1
68155051 2300 2150  68618816  68605218  68530420  4  1 2 1 1
68157771 2300 2150  68666416  68632418  68557620  2 -8 2 2 2
68159131 2300 2150  68673216  68639218  68564420 -8  1 2 1 1
68160485   39   11  73127216  72841618  72515220 -8  1 2 2 2
68160489   39   11  73134016  72848418  72522020 -8  1 2 2 2
68173407 2348 2174  68707216  68673218  68598420 -8  4 2 2 1
68174767 2348 2174  68720816  68686818  68612020  .  4 1 1 .
68180887 2348 2174  68754816  68714018  68632420 -8  1 2 1 1
68180891 2348 2174  68754816  68714018  68632420  .  1 2 1 .
68184971 2372 2186  68761616  68720818  68639220 -8  . . . 1
68185647 2372 2186  68768416  68727618  68646020 -8  4 2 2 2
68187687 2372 2186  68775216  68734418  68659620 -8  4 2 1 1
68187691 2372 2186  68775216  68734418  68659620 -8  4 2 1 1
68191771 2372 2186  68809216  68775218        -9 -8  1 2 2 2
68193127 2372 2186  68816016  68782018  68707220 -8  4 2 2 2
68195167 2372 2186  68822816  68795618  68720820 -8  4 2 1 1
68195171 2372 2186  68822816  68795618  68720820 -8  4 2 1 1
68195851 2372 2186  68829616  68802418  68727620 -8  1 2 1 1
68197211 2396 2198  68836416  68809218  68734420  .  1 2 1 .
68197887 2396 2198  68843216  68816018  68741220 -8  1 2 2 2
68197899 2396 2198  68843216  68817378  68754820 -8 -8 2 2 2
68197903 2396 2198  68843216  68816018  68741220 -8 -8 2 2 2
68199247 2396 2198  76506816  76153218  75595620 -8  1 1 1 1
68207407 2396 2198  68863616  68836418  68775220 -8  4 2 1 1
68207411 2396 2198  68863616  68836418  68775220 -8  4 2 1 1
68211487 2420 2210  68877216  68850018  68788820 -8  4 2 2 2
68214207 2420 2210  68890816  68863618  68802420 -8  1 2 2 2
68214887 2420 2210  68897616  68870418  68809220  . -8 2 1 .
68214891 2420 2210  68897616  68870418  68809220  .  1 2 1 .
68216247 2420 2210  68904416  68877218  68816020 -8  1 2 1 1
68218287 2420 2210  68911216  68884018  68822820 -8 -8 2 2 2
68230527 2444 2222  68979216  68965618  68897620  . -8 2 2 .
68231223 2444 2222  68986016  68972418  68904420 -8  4 2 2 2
68238011 2468 2234  69006416  68986018  68911220 -8  1 2 1 1
68262487 2516 2258  69081216  69047218  68965620 -8  2 2 1 1
68266567 2516 2258  69101616  69067618  68986020 -8  4 2 2 2
68278127 2540 2270  69142416  69108418  69020020 -8  4 2 2 2
68288327 2564 2282  69162816  69128818  69033620 -8  1 2 1 1
68288331 2564 2282  69162816  69128818  69033620 -8  1 2 1 1
68291731 2564 2282  69169616  69135618  69040420 -8  4 2 2 2
68293087 2564 2282  69176416  69142418  69047220 -8  4 2 1 1
68293091 2564 2282  69176416  69142418  69047220 -8  1 2 1 1
68293095 2564 2282  69176416  69143098  69054020 -8  1 1 1 1
68293099 2564 2282  69176416  69142418  69047220 -8  1 1 1 1
68293168 2108 2054  68278816  68272018        -9 -8  4 2 2 2
end
label values psu psu
label values strata strata
label values cg_semp cg_semp
label def cg_semp -8 "inapplicable", modify
label def cg_semp 2 "Yes, self-employed only", modify
label def cg_semp 4 "No", modify
label values ce_semp ce_semp
label def ce_semp -8 "inapplicable", modify
label def ce_semp 1 "Yes, employed only", modify
label def ce_semp 2 "Yes, self-employed only", modify
label def ce_semp 3 "Both employed and self-employed", modify
label def ce_semp 4 "No", modify
label values ce_parent0plus ce_parent0plus
label def ce_parent0plus 1 "Yes", modify
label def ce_parent0plus 2 "No", modify
label values ce_couple ce_couple
label def ce_couple 1 "Yes", modify
label def ce_couple 2 "No", modify
label values cg_couple cg_couple
label def cg_couple 1 "Yes", modify
label def cg_couple 2 "No", modify

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

reshape long `stublist', i(pidp) j(_j) string

foreach s of local stublist {
local t = strtoname(substr(`"`s'"', 2, .))
local stublist: subinstr local stublist `"`s'"' `"@`t'"'
}
drop if psu==.

gen int date = cond(_j == "cg_", tm(2021m1), tm(2020m9))
format date %tmMonth_CCYY

drop _j