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]

From |
"Gupta, Ani" <agupta@compasslexecon.com> |

To |
"statalist@hsphsun2.harvard.edu" <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 00:16:13 +0000 |

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 -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of daniel klein Sent: Thursday, January 03, 2013 4:01 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: How can I label a variable with a combination of two value labels First, in your code you keep referring to <lbl>, where you should refer to either <lbl_c> or <lbl_p>. However, these migth be typos and it is unlikely they cause the "invalid syntax" errors. Anyway, if your labels do not contain [compound (double)] quotes, a simple forv j = 1/2 { forv k = 1/20 { la var var`j'_`k' "`: label lbl_c `j'' `: label lbl_p `k''" } } should do the trick. If this does not work, I guess we need more information on what your labels look like. Best Daniel -- I have two value labels lbl_c and lbl_p that take 2 and 20 values respectively I also have 40 variables of the type var`i'_`j' where i = 1/2 and `j' = 1/20 I want to label each variable var`i'_`j' with a combination of lbl_c `i' and lbl_p `j' For a single label I would use -- label variable var`i' "`: label lbl `i' '" I tried various combinations of quotes of the form -- label variable var`i'_`j' "`"`: label lbl `i' '" "`: label lbl `j' '"'", but I always get a syntax error message. Does anyone know the correct combination of quotes that would make this work? * * 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/

**Follow-Ups**:**Re: st: How can I label a variable with a combination of two value labels***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**Re: st: How can I label a variable with a combination of two value labels***From:*daniel klein <klein.daniel.81@gmail.com>

- Prev by Date:
**st: xtmixed** - Next by Date:
**Re: st: xtmixed** - Previous by thread:
**Re: st: How can I label a variable with a combination of two value labels** - Next by thread:
**Re: st: How can I label a variable with a combination of two value labels** - Index(es):