Home  /  Resources & support  /  FAQs  /  Using a value label multiple times

Can I apply the label values command to more than one variable at the same time? I want to attach the same value labels to several variables.

Title   Using a value label multiple times
Author Paul Lin, StataCorp

Yes. Say you have a survey, and the codings for the variables q1, q2, ..., q10 are all the same. You create a value label,

        . label define yesno 0 "no" 1 "yes"

and you can use it ten times:

        . label values q1 yesno
        . label values q2 yesno
        ...
        . label values q10 yesno

Actually, you can save time by typing

        . foreach var of varlist q1-q10 {
                 label values `var' yesno
          }

See help foreach in Stata, or see [P] foreach.