Benoit Dulong <[email protected]> wrote:
> Before I reshape my data, I do not have any variable
> label.
> After I reshape my data, every variable has a
> variable label.
> Is this normal ?
> Is it possible to reshape and get variables without
> labels ?
Ricardo Ovaldia
> I think this is needed for reshape to go back and
> forth from wide to long. You need to relabel after the
> reshape. One way to do this is with the -foreach-
> command:
>
> foreach var of varlist /*
> */ q1x1 q2ax1 q2bx1 q3x1 q4x1 q5ax1 q5bx1 q6x1 fx1 /*
> */ q1x2 q2ax2 q2bx2 q3x2 q4x2 q5ax2 q5bx2 q6x2 fx2 /*
> */ q1x3 q2ax3 q2bx3 q3x3 q4x3 q5ax3 q5bx3 q6x3 fx3 /*
> */ q1x4 q2ax4 q2bx4 q3x4 q4x4 q5ax4 q5bx4 q6x4 fx4 /*
> */ q1x5 q2ax5 q2bx5 q3x5 q4x5 q5ax5 q5bx5 q6x5 fx5 /*
> */ q1x6 q2ax6 q2bx6 q3x6 q4x6 q5ax6 q5bx6 q6x6 fx6 /*
> */ q1x7 q2ax7 q2bx7 q3x7 q4x7 q5ax7 q5bx7 q6x7 fx7 /*
> */ q1x8 q2ax8 q2bx8 q3x8 q4x8 q5ax8 q5bx8 q6x8 fx8 {
>
> rename `var' "`var'"
>
> }
>
Ricardo's code will not affect the variable
labels. In fact, it will not work.
. rename `var' "`var'"
is an attempt to -rename- each variable
with its own existing name, whereas a new
variable name is needed as the second
argument.
To remove variable labels you don't want,
foreach v of var <varlist> {
label var `v'
}
i.e. assign an empty label in each case.
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/