Dear Statalist,
I tried following the solutions proposed to other users who faced the same problem than mine but the code just won't work. To sum things up, I am trying to give as variable label the content of whatever is written in the first observation. I used a classic loop for each variable that creates a local that stores the variable name but when I run my code and put the tracer one, Stata doesn't detect any local.
And then
I get this from the tracer :
- label variable `va' "`l`va''"
= label variable var493 ""
Which means the local is empty, right? There is a very long series of lines between the two blocks of code, including two reshapes (wide>long then long>wide and a use of frames. I recreated a simple dataex example summarizing my problem :
A very important detail : Some of the soon-to-be labels contain double quotes that I would like to keep. If possible, I would like a solution to my problem that is compatible with the label having double quotes. Thank you for your help !
EDIT : After doing a macro list command after the local command it seems that there is no local named l`var' so the problem must arise from here. What did I do wrong here ?
I tried following the solutions proposed to other users who faced the same problem than mine but the code just won't work. To sum things up, I am trying to give as variable label the content of whatever is written in the first observation. I used a classic loop for each variable that creates a local that stores the variable name but when I run my code and put the tracer one, Stata doesn't detect any local.
Code:
foreach va of varlist var* { local l`va' : variable label `va' }
Code:
foreach va of varlist var* { label variable `va' "`l`va''" }
- label variable `va' "`l`va''"
= label variable var493 ""
Which means the local is empty, right? There is a very long series of lines between the two blocks of code, including two reshapes (wide>long then long>wide and a use of frames. I recreated a simple dataex example summarizing my problem :
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str50(var1 var2 var3) "this should be considered a label" "this too" "this too" end
EDIT : After doing a macro list command after the local command it seems that there is no local named l`var' so the problem must arise from here. What did I do wrong here ?
Comment