Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How can I label a variable with a combination of two value labels


From   daniel klein <klein.daniel.81@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How can I label a variable with a combination of two value labels
Date   Fri, 4 Jan 2013 09:40:35 +0100

Ani,

as I said, you need to give us much more details. How exactly do your
labels look like? What exactly did you type? What exactly did Stata
respond? Please read the FAQs on expressions like "it didn't work"
(http://www.stata.com/support/faqs/resources/statalist-faq/#noanswer).

Best way to provide such information is a reproducible example. Here
is mine, and it works perfect for me

clear

// create value labels with multiple words
la de lbl_c 1 "foo bar" 2 "foo bar foobar"
la de lbl_p 1 "onw two three" ///
	2 "four five six" ///
	3 "seven eight nine"
	
// create variables and labels on the fly
forv j = 1/2 {
	forv k = 1/3 {
		g byte var`j'_`k' = 42
		la var var`j'_`k' "`: label lbl_c `j'' `: label lbl_p `k''"
	}
}

// see result
d

Best
Daniel

-- 
Hi Daniel,

Thanks for the response. Yes, I should have referred to them as lbl_c
and lbl_p throughout.

I tried using your suggested method, as below:

forvalues i = 1/20 {
	forvalues j = 1/2 {
		label variable var`i'_`j' "`: label lbl_c `j'' `: label lbl_p `i''"
	}
}

But it didn't work. The problem, I think, is that both sets of labels
include multiple words separated by spaces.

Thanks again,

Ani
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index