In your last foreach loop:
foreach v of var `rshp' {
label variable `v' "`l`lrshp''"
}
You are iterating thru values of `rshp' but are selecting labels from
something called `l`lrshp''.
I suspect that something should be `l`rshp''.
(i.e., you have the "l" in there twice.)
-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Andrea Bennett
Sent: Monday, June 16, 2008 3:06 PM
To: [email protected]
Subject: st: UPDATE: once again -reshape- and labels
Dear Statalisters,
So with a more detailed question again (see previous post by me). The
data set contains these variables: id, Ax1-Ax10, Bx1-Bx10, Cx1-Cx10.
Every group (e.g. Ax1-Ax10) has the very same label which should be
applied to the new variables after reshape. This is the code I got so
far:
/* store label of each group of variables */
local lrshp "Ax1 Bx1 Cx1"
foreach v of var `lrshp' {
local l`v' : variable label `v'
}
/* reshape */
local rshp "Ax Bx Cx"
quietly reshape long `rshp', i(id) j(wave) /* giving me a data set
with the variables: id, Ax, Bx, Cx, wave */
/* set label */
foreach v of var `rshp' {
label variable `v' "`l`lrshp''"
}
This way, Ax gets the correct label but Bx and Cx get the label of Ax.
I seem to do something wrong when iterating at the end. I just really
don't see the point.
Many thanks for the consideration,
Andrea
*
* 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/
-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information. If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system. Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.
*
* 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/