Hello,

I need to organize my data and convert it from wide to long. Since I have to many variables I use the command "set maxvar 32767, permanently".
After that I run the following code:
ds cg_* ce_*
local varlist `r(varlist)'
local varlist: subinstr local varlist " " "_@ ", all
local varlist `varlist'_@

reshape long `varlist', i(pidp) j(_j) string
replace _j = cond(_j=="ce","September 2020","January 2021")

drop if psu==.

I didn´t get the results that I want. I still have the variables with the "cg_" and "ce_" and the only month that appears in the rows in january 2021. Can you help me to solve this problem? Thank you in advance.
I send an example of the dataset below:

* Example generated by -dataex-. For more info, type help dataex
clear
input long(pidp psu) int strata byte(ce_semp cg_semp cg_parent5plus ce_parent5plus cg_couple ce_couple cg_sex_cv ce_sex_cv i_qfhigh)
76165 19 6 1 -8 2 2 1 1 2 2 -8
280165 67 15 -8 . . 1 . 1 . 2 -8
469205 106 25 -8 . . 2 . 2 . 2 15
732365 157 43 -8 -8 2 2 2 2 1 1 -8
1587125 215 65 3 -8 2 2 2 2 2 2 -8
4849085 560 148 1 -8 2 2 1 1 1 1 -8
68002725 1 1 4 -8 2 2 2 2 2 2 -8
68008847 2012 2006 1 -8 2 2 2 2 2 2 -8
68010887 2012 2006 1 -8 2 2 1 1 2 2 -8
68029931 2060 2030 . -8 1 . 1 . 1 . -8
68031967 2060 2030 4 4 2 2 2 2 2 2 -8
68035365 11 4 4 -8 2 2 2 2 1 1 -8
68035367 2060 2030 1 -8 2 2 1 1 1 1 -8
68041487 2084 2042 1 -8 1 1 1 1 2 2 -8
68041491 2084 2042 . -8 1 . 1 . 1 . -8
68045567 2084 2042 1 -8 2 2 2 2 2 2 -8
68051007 2108 2054 2 -8 2 2 1 1 1 1 -8
68051011 2108 2054 1 -8 2 2 1 1 2 2 -8
68058487 2108 2054 4 -8 2 2 1 1 1 1 -8
68058491 2108 2054 4 -8 2 2 1 1 2 2 -8
68060531 2108 2054 1 -8 1 1 1 1 2 2 -8
68060533 18 6 4 -8 2 2 1 1 2 2 -8
68060537 18 6 4 -8 2 2 1 1 1 1 -8
68061288 2012 2006 -8 . . 2 . 1 . 2 -8
68063247 2132 2066 1 -8 1 1 1 1 2 2 -8
68063927 2132 2066 1 -8 1 1 1 1 2 2 -8
68063931 2132 2066 -8 -8 1 1 1 1 1 1 -8
68064605 18 6 4 -8 2 2 1 1 1 1 -8
68064609 18 6 4 -8 2 2 1 1 2 2 -8
68068007 2132 2066 1 -8 2 2 1 1 1 1 -8
68068011 2132 2066 1 . . 2 . 2 . 2 -8
68068082 2012 2006 2 -8 2 2 1 1 1 1 -8
68097245 25 8 4 -8 2 2 2 2 2 2 -8
68097927 2180 2090 4 -8 2 2 2 2 2 2 -8
68112211 2228 2114 1 . . 1 . 1 . 2 -8
68120367 2228 2114 4 -8 2 2 2 2 2 2 -8
68120375 2228 2114 1 -8 1 2 2 2 2 2 -8
68125127 2252 2126 1 -8 1 1 1 1 2 2 -8
68125131 2252 2126 1 -8 2 2 1 1 1 1 -8
68125135 2252 2126 1 -8 2 2 2 2 2 2 -8
68133285 34 11 4 -8 2 2 2 2 2 2 -8
68133289 34 11 4 -8 2 2 1 1 2 2 -8
68136009 34 11 1 -8 1 1 2 2 2 2 -8
68137365 34 11 -8 -8 2 2 2 2 2 2 -8
68138045 34 11 4 -8 2 2 1 1 1 1 -8
68138049 34 11 4 -8 2 2 1 1 2 2 -8
68138051 2276 2138 4 -8 2 2 1 1 2 2 -8
68144847 2276 2138 1 -8 2 2 1 1 1 1 -8
68144851 2276 2138 1 -8 1 1 1 1 2 2 -8
68148247 2300 2150 -8 -8 2 2 1 1 1 1 -8
68148251 2300 2150 4 . . 2 . 1 . 2 -8
68150967 2300 2150 1 . . 2 . 1 . 1 -8
68150971 2300 2150 1 -8 2 2 1 1 2 2 -8
68150975 2300 2150 1 -8 2 2 2 2 1 1 -8
68155047 2300 2150 -8 4 1 1 1 1 2 2 -8
68155051 2300 2150 1 4 1 1 1 1 1 1 -8
68157771 2300 2150 -8 2 2 2 2 2 2 2 -8
68159131 2300 2150 1 -8 1 1 1 1 2 2 -8
68160485 39 11 1 -8 1 1 2 2 2 2 -8
68160489 39 11 1 -8 2 2 2 2 1 1 -8
68173407 2348 2174 4 -8 2 2 1 2 2 2 -8
68174767 2348 2174 4 . . 1 . 1 . 2 -8
68180887 2348 2174 1 -8 1 1 1 1 2 2 -8
68180891 2348 2174 1 . . 1 . 1 . 1 -8
68184971 2372 2186 . -8 1 . 1 . 2 . -8
68185647 2372 2186 4 -8 2 2 2 2 2 2 -8
68187687 2372 2186 4 -8 1 1 1 1 1 1 -8
68187691 2372 2186 4 -8 1 1 1 1 2 2 -8
68191771 2372 2186 1 -8 1 1 2 2 2 2 -8
68193127 2372 2186 4 -8 1 1 2 2 2 2 -8
68195167 2372 2186 4 -8 2 2 1 1 1 1 -8
68195171 2372 2186 4 -8 2 2 1 1 2 2 -8
68195851 2372 2186 1 -8 2 2 1 1 2 2 -8
68197211 2396 2198 1 . . 2 . 1 . 2 -8
68197887 2396 2198 1 -8 1 1 2 2 2 2 -8
68197899 2396 2198 -8 -8 2 1 2 2 2 2 -8
68197903 2396 2198 -8 -8 2 2 2 2 1 1 -8
68199247 2396 2198 1 -8 2 2 1 1 1 1 -8
68207407 2396 2198 4 -8 2 2 1 1 2 2 -8
68207411 2396 2198 4 -8 2 2 1 1 1 1 -8
68211487 2420 2210 4 -8 2 2 2 2 1 1 -8
68214207 2420 2210 1 -8 2 2 2 2 1 1 -8
68214887 2420 2210 -8 . . 1 . 1 . 1 -8
68214891 2420 2210 1 . . 1 . 1 . 2 -8
68216247 2420 2210 1 -8 1 1 1 1 2 2 -8
68218287 2420 2210 -8 -8 2 2 2 2 1 1 -8
68230527 2444 2222 -8 . . 1 . 2 . 2 -8
68231223 2444 2222 4 -8 2 2 2 2 2 2 -8
68238011 2468 2234 1 -8 2 2 1 1 2 2 -8
68262487 2516 2258 2 -8 2 2 1 1 1 1 -8
68266567 2516 2258 4 -8 2 2 2 2 2 2 -8
68278127 2540 2270 4 -8 2 2 2 2 2 2 -8
68288327 2564 2282 1 -8 1 1 1 1 2 2 -8
68288331 2564 2282 1 -8 1 1 1 1 1 1 -8
68291731 2564 2282 4 -8 2 2 2 2 2 2 -8
68293087 2564 2282 4 -8 1 1 1 1 2 2 -8
68293091 2564 2282 1 -8 1 1 1 1 1 1 -8
68293095 2564 2282 1 -8 1 1 1 1 1 1 -8
68293099 2564 2282 1 -8 2 2 1 1 1 1 -8
68293168 2108 2054 4 -8 2 2 2 2 1 1 -8
end
label values psu psu
label values strata strata
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 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 cg_parent5plus cg_parent5plus
label def cg_parent5plus 1 "Yes", modify
label def cg_parent5plus 2 "No", modify
label values ce_parent5plus ce_parent5plus
label def ce_parent5plus 1 "Yes", modify
label def ce_parent5plus 2 "No", modify
label values cg_couple cg_couple
label def cg_couple 1 "Yes", modify
label def cg_couple 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_sex_cv cg_sex_cv
label def cg_sex_cv 1 "Male", modify
label def cg_sex_cv 2 "Female", modify
label values ce_sex_cv ce_sex_cv
label def ce_sex_cv 1 "Male", modify
label def ce_sex_cv 2 "Female", modify
label values i_qfhigh i_qfhigh
label def i_qfhigh -8 "inapplicable", modify
label def i_qfhigh 15 "Other school (inc. school leaving exam certificate or matriculation)", modify
[/CODE]