Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: question about speedy labelling


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: question about speedy labelling
Date   Fri, 22 Nov 2002 17:56:42 -0000

Radu Ban 
 
> I have the variable labels for my dataset as two variables. i.e:
> 
> var_name    var_label
> var1            label1
> var2            label2
> .....             .......
> varn            labeln
> 
> var1 through varn all exist as variables in my dataset. is 
> there a speedy
> way to assign labels, taking advantage of these two variables?
> 

Essentially the same question was asked by 
Hans Baumgartner on Tuesday. 

forval i = 1 / <nvars> { 
	local name = var_name[`i']
	local label = var_label[`i'] 
	label var `name' `"`label'"' 
} 

where for <nvars> you should plug 
in the number of variables. 

Alternatively, 

local i = 1 
foreach v of var * {
	local label = var_label[`i'] 
	label var `v' `"`label'"' 
	local i = `i' + 1 
} 

Nick 
[email protected] 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index