Nick,
thank you very much for your flexible suggestion.
I would take it.
Best regards,
Rose.
----- Original Message -----
From: Nick Cox <[email protected]>
To: <[email protected]>
Subject: RE: st: AW: how to make the labels in the localname to be independent of each other?
Date: 2009-8-18 02:23:13
You don't _need_ to put them in one (big) macro. You could just put them
in several. Here is a sketch.
use firstdata
foreach v in var * {
local l_`v' "`: var label `v''"
}
use seconddata
foreach v in var * {
label var `v' "`l_`v''"
}
Nick
[email protected]
[email protected]
Martin, thank you for your quick reply.
I just take a simply example in my previous posting. In fact, I want to
store the labels for certain variables in one dta into a localname and
then feed them to other variables in the other dta. However, the labels
for certain variables have space, which make things troublesome.
From: Martin Weiss <[email protected]>
If you really do want -_all- variables, then your -word count- is a
rather
roundabout and hazardous way to get the # of variables. Why not just
*************
di in red "# of vars in the dataset: " c(k)
*************
[email protected]
I generate a localname to stand for the var labels of certain variables.
However, there are spaces in the labels of certain variables.
How to let stata treat each label as a complete unit?
For example,
clear
input x y
1 2
3 9
end
l
la var x "the first"
la var y "the second"
foreach i of varlist _all {
loc labels "`labels' `: var l `i''"
}
di "`labels'"
the first the second
di "`: word count `labels''"
4
In fact my purpose is to generate a localname including two labels, and
the
word count
of it is 2.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/