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 |
Nick Cox <n.j.cox@durham.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: How do I put a value of a local macro into a variable label |

Date |
Fri, 27 Jan 2012 15:02:21 +0000 |

This is good technique, but your problem has a different structure from the original poster's, in that you end up with two nested loops for a cross-combination of arguments. The original question called for going through two lists of arguments in parallel. Nick n.j.cox@durham.ac.uk Pamela Oliver It is possible simply to write local label something label var varname " `label' " I do this often, generally to create composite labels within loops. Example: local b Black local w White local h Hispanic local viol violence local drug drug local theft theft local rob robbery foreach r in b w h { foreach c in v d t { label var `r'`c'o "``r'' ``c'' arrest rate" } } Note that there are double markers for the locals. `r' would refer to b w h, while ``r'' refers to Black White Hispanic. my variable names follow a standard format with the race indicator being a single letter and a shortened name of the offense being lengthened. I also have a system of prefixes and postfixes, so that the o for example is my symbol for rate, and I left a prefix out of this example. I might also at times create locals for prefixes or postfixes. * * 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/

**References**:**Re: st: How do I put a value of a local macro into a variable label***From:*Pamela Oliver <pamelaoliver1180@gmail.com>

- Prev by Date:
**Re: st: How do I put a value of a local macro into a variable label** - Next by Date:
**st: Generate Estimates for Dependent Variable using OLS Regression** - Previous by thread:
**Re: st: How do I put a value of a local macro into a variable label** - Next by thread:
**st: general-to-specific GETS algorithm** - Index(es):