Hello,
I used the following command to reshape data from wide to long (example of the data below).
Code:
ds cg_* ce_* local varlist = ustrregexra("`r(varlist)'","^(cg|ce)_","@_") reshape long `varlist', i(pidp) j(_j) string replace _j = cond(_j=="ce","September 2020","January 2021")
However, when I run this command I get the following error: "variable 0_welsh implied name too long". I tried to delete this variable (because it was not relevanr) but when I run the command again appears the same error with other variables. Can you help me to solve this?
Thank you in advance.
Example of the data:
* Example generated by -dataex-. For more info, type help dataex clear input long(pidp pid) int i_strata byte(ce_semp cg_semp cg_parent5plus ce_parent5plus cg_couple ce_couple cg_sex_cv ce_sex_cv i_qfhigh) 76165 10689869 6 1 -8 2 2 1 1 2 2 -8 280165 12430439 15 -8 . . 1 . 1 . 2 -8 469205 13857142 25 -8 . . 2 . 2 . 2 15 732365 15752658 43 -8 -8 2 2 2 2 1 1 -8 1587125 17870879 65 3 -8 2 2 2 2 2 2 -8 4849085 176725733 148 1 -8 2 2 1 1 1 1 -8 68002725 10023526 1 4 -8 2 2 2 2 2 2 -8 68008847 -8 2006 1 -8 2 2 2 2 2 2 -8 68010887 -8 2006 1 -8 2 2 1 1 2 2 -8 68031967 -8 2030 4 4 2 2 2 2 2 2 -8 68035365 10403086 4 4 -8 2 2 2 2 1 1 -8 68035367 -8 2030 1 -8 2 2 1 1 1 1 -8 68041487 -8 2042 1 -8 1 1 1 1 2 2 -8 68045567 -8 2042 1 -8 2 2 2 2 2 2 -8 68051007 -8 2054 2 -8 2 2 1 1 1 1 -8 68051011 -8 2054 1 -8 2 2 1 1 2 2 -8 68058487 -8 2054 4 -8 2 2 1 1 1 1 -8 68058491 -8 2054 4 -8 2 2 1 1 2 2 -8 68060531 -8 2054 1 -8 1 1 1 1 2 2 -8 68060533 160066204 6 4 -8 2 2 1 1 2 2 -8 68060537 160066239 6 4 -8 2 2 1 1 1 1 -8 68061288 -8 2006 -8 . . 2 . 1 . 2 -8 68063247 -8 2066 1 -8 1 1 1 1 2 2 -8 68063927 -8 2066 1 -8 1 1 1 1 2 2 -8 68063931 -8 2066 -8 -8 1 1 1 1 1 1 -8 68064605 10653872 6 4 -8 2 2 1 1 1 1 -8 68064609 10653902 6 4 -8 2 2 1 1 2 2 -8 68068007 -8 2066 1 -8 2 2 1 1 1 1 -8 68068011 -8 2066 1 . . 2 . 2 . 2 -8 68068082 -8 2006 2 -8 2 2 1 1 1 1 -8 68097245 10913629 8 4 -8 2 2 2 2 2 2 -8 68097927 -8 2090 4 -8 2 2 2 2 2 2 -8 68112211 -8 2114 1 . . 1 . 1 . 2 -8 68120367 -8 2114 4 -8 2 2 2 2 2 2 -8 68120375 -8 2114 1 -8 1 2 2 2 2 2 -8 68125127 -8 2126 1 -8 1 1 1 1 2 2 -8 68125131 -8 2126 1 -8 2 2 1 1 1 1 -8 68125135 -8 2126 1 -8 2 2 2 2 2 2 -8 68133285 11218193 11 4 -8 2 2 2 2 2 2 -8 68133289 11218282 11 4 -8 2 2 1 1 2 2 -8 68136009 11234989 11 1 -8 1 1 2 2 2 2 -8 68137365 11240547 11 -8 -8 2 2 2 2 2 2 -8 68138045 11242787 11 4 -8 2 2 1 1 1 1 -8 68138049 11242817 11 4 -8 2 2 1 1 2 2 -8 68138051 -8 2138 4 -8 2 2 1 1 2 2 -8 68144847 -8 2138 1 -8 2 2 1 1 1 1 -8 68144851 -8 2138 1 -8 1 1 1 1 2 2 -8 68148247 -8 2150 -8 -8 2 2 1 1 1 1 -8 68148251 -8 2150 4 . . 2 . 1 . 2 -8 68150967 -8 2150 1 . . 2 . 1 . 1 -8 68150971 -8 2150 1 -8 2 2 1 1 2 2 -8 68150975 -8 2150 1 -8 2 2 2 2 1 1 -8 68155047 -8 2150 -8 4 1 1 1 1 2 2 -8 68155051 -8 2150 1 4 1 1 1 1 1 1 -8 68157771 -8 2150 -8 2 2 2 2 2 2 2 -8 68159131 -8 2150 1 -8 1 1 1 1 2 2 -8 68160485 11418567 11 1 -8 1 1 2 2 2 2 -8 68160489 11418591 11 1 -8 2 2 2 2 1 1 -8 68173407 -8 2174 4 -8 2 2 1 2 2 2 -8 68174767 -8 2174 4 . . 1 . 1 . 2 -8 68180887 -8 2174 1 -8 1 1 1 1 2 2 -8 68180891 -8 2174 1 . . 1 . 1 . 1 -8 68185647 -8 2186 4 -8 2 2 2 2 2 2 -8 68187687 -8 2186 4 -8 1 1 1 1 1 1 -8 68187691 -8 2186 4 -8 1 1 1 1 2 2 -8 68191771 -8 2186 1 -8 1 1 2 2 2 2 -8 68193127 -8 2186 4 -8 1 1 2 2 2 2 -8 68195167 -8 2186 4 -8 2 2 1 1 1 1 -8 68195171 -8 2186 4 -8 2 2 1 1 2 2 -8 68195851 -8 2186 1 -8 2 2 1 1 2 2 -8 68197211 -8 2198 1 . . 2 . 1 . 2 -8 68197887 -8 2198 1 -8 1 1 2 2 2 2 -8 68197899 -8 2198 -8 -8 2 1 2 2 2 2 -8 68197903 -8 2198 -8 -8 2 2 2 2 1 1 -8 68199247 -8 2198 1 -8 2 2 1 1 1 1 -8 68207407 -8 2198 4 -8 2 2 1 1 2 2 -8 68207411 -8 2198 4 -8 2 2 1 1 1 1 -8 68211487 -8 2210 4 -8 2 2 2 2 1 1 -8 68214207 -8 2210 1 -8 2 2 2 2 1 1 -8 68214887 -8 2210 -8 . . 1 . 1 . 1 -8 68214891 -8 2210 1 . . 1 . 1 . 2 -8 68216247 -8 2210 1 -8 1 1 1 1 2 2 -8 68218287 -8 2210 -8 -8 2 2 2 2 1 1 -8 68230527 -8 2222 -8 . . 1 . 2 . 2 -8 68231223 -8 2222 4 -8 2 2 2 2 2 2 -8 68238011 -8 2234 1 -8 2 2 1 1 2 2 -8 68262487 -8 2258 2 -8 2 2 1 1 1 1 -8 68266567 -8 2258 4 -8 2 2 2 2 2 2 -8 68278127 -8 2270 4 -8 2 2 2 2 2 2 -8 68288327 -8 2282 1 -8 1 1 1 1 2 2 -8 68288331 -8 2282 1 -8 1 1 1 1 1 1 -8 68291731 -8 2282 4 -8 2 2 2 2 2 2 -8 68293087 -8 2282 4 -8 1 1 1 1 2 2 -8 68293091 -8 2282 1 -8 1 1 1 1 1 1 -8 68293095 -8 2282 1 -8 1 1 1 1 1 1 -8 68293099 -8 2282 1 -8 2 2 1 1 1 1 -8 68293168 -8 2054 4 -8 2 2 2 2 1 1 -8 68294447 -8 2294 4 4 2 2 1 1 1 1 -8 68294451 -8 2294 1 1 2 2 1 1 2 2 -8 68297845 12521361 15 4 -8 2 2 1 1 1 1 -8 end label values pid pid label def pid -8 "inapplicable", modify label values i_strata i_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 1 "Yes, employed only", 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
Related Posts with Error reshape wide to long: "variable 0_welsh implied name too long"
Diff-in-Diff / Pooled / Random EffectHi everyone, I am concluding my master’s degree and would very much appreciate your experience on…
Sorting and droppingHi everyone, I have a dataset consisting of 10 numeric variables. I was wondering to know how can I …
why stata did not read my imported excel? all the numbers in my excel are showed in red. stata shows no observationArray i imput my excel, stata shows this …
vce2way works in Stata 15.1 but not in 16Dear All, I find that (ssc install) -vce2way- command works in Stata 15.1 but not in Stata 16 in the…
How to show persistence using panel dataDear stata users and experts, My data is firm year panel data, i.e., I have observations at firm le…
Subscribe to:
Post Comments (Atom)
0 Response to Error reshape wide to long: "variable 0_welsh implied name too long"
Post a Comment