Bookmark and Share

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]

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


From   Charalambos Karagiannakis <karagiannakis.charalambos@ucy.ac.cy>
To   statalist@hsphsun2.harvard.edu
Subject   st: How Can I Store a Variable's Label to Label Another Variable?
Date   Wed, 24 Oct 2012 12:46:43 +0300

Hello. 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’?

Thanks in advance.

 

Charalampos K.

 



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index