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   "Gupta, Ani" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: How can I label a variable with a combination of two value labels
Date   Fri, 4 Jan 2013 22:54:42 +0000

Daniel,

Thank you, that worked. Apparently I was using extra double quotes.

Ani

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of daniel klein
Sent: Friday, January 04, 2013 12:41 AM
To: [email protected]
Subject: Re: st: How can I label a variable with a combination of two value labels

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/


*
*   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