Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to assign value labels to several variables at once?

From   Joseph Coveney <>
To   Statalist <>
Subject   Re: st: How to assign value labels to several variables at once?
Date   Mon, 12 Jun 2006 10:39:20 +0900

Buddy wrote:

I'm crossing over from SAS, so am having problems with
some elementary procedures, so appreciate your

I'm using STATA 8.

I understand how to assign one variable to one value label
(i.e. label values variablename labelname)

I'm wondering how to assign several variables to the
same label name?

I.e. label values variable1 variable 2 labelname?


Stata's help files and user's manuals will indicate that the command can
take a list of variables by displaying the command's argument as *varlist*
in the syntax diagram.  If the command can take on only a single variable,
it will say *variable*.  The help file indicates that -label values- takes
on only a single variable.

You can, nevertheless, easily label values of a list of variables by using
a -foreach- loop; it's three lines of code, including braces.

Joseph Coveney

foreach var of varlist variable1 variable 2 {
   label values `var' labelname

*   For searches and help try:

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