Stata: Data Analysis and Statistical Software
   >> 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
Date March 1997; updated February 2003

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.

Bookmark and Share 
FAQs
What's new?
Statistics
Data management
Graphics
Programming Stata
Mata
Resources
Internet capabilities
Stata for Windows
Stata for Unix
Stata for Mac
Technical support
Like us on Facebook Follow us on Twitter Follow us on LinkedIn Google+ Watch us on YouTube
Follow us
© Copyright 1996–2013 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index   |   View mobile site