Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: How Can I Store a Variable's Label to Label Another Variable? |

Date |
Wed, 24 Oct 2012 10:55:42 +0100 |

-copydesc- (SSC) is a user-written program; you are asked to explain where it comes from. (By the way, -copydesc- morphed into -clonevar-, which is now an official command. -copydesc- is only of real use to people still using Stata 6 or 7. -clonevar- was added to Stata 8.) That said, you are correct that -copydesc- is not the answer here, and the solution to your problem is more direct. foreach X of varlist inflation_r wages_a { generate `X'_1 = `X'/2 local label : variable label `X' label variable `X'_1 `"Half of `label''"' } See -help extended fcn-. On Wed, Oct 24, 2012 at 10:46 AM, Charalambos Karagiannakis <karagiannakis.charalambos@ucy.ac.cy> wrote: > The loop below labels the new variables using the name of the > original variables (see line 3). Is there any way to label the new variable > using the label (instead of the name) of the original variable? I found the > command ‘copydesc’ however that command is used when you want to copy the > description of another variable exactly as it is. In my case below the label > of the new variable contains a couple of other words as well. > > > > local i = 1 > > foreach X of varlist inflation_r wages_a { > > generate `X'_1 = `X'/2 > > label variable `X'_1 `"Half of `X'"' > > } > > > > Since command ‘describe’ gives also the variables’ labels I tried to see > (using the ‘return’ command) whether it saves any results. However, is seems > like it does not save the labels. Is there any way to label variable `X'_1 > as: Half of ‘and then here I would like the label of variable X instead of > the name of variable X’? * * 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/

**References**:**st: How Can I Store a Variable's Label to Label Another Variable?***From:*Charalambos Karagiannakis <karagiannakis.charalambos@ucy.ac.cy>

- Prev by Date:
**Re: st: Adjusted Prevalence from Logistic models** - Next by Date:
**st: sum issue (wrong values)** - Previous by thread:
**st: How Can I Store a Variable's Label to Label Another Variable?** - Next by thread:
**st: sum issue (wrong values)** - Index(es):