Stata
Products Purchase Support Company
Search
   >> Home >> Resources & support >> FAQs >> Using a value label multiple times Bookmark and Share

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 that 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.

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
Resources & support
FAQs
Technical support
NetCourses
Short courses
Users Group meetings
Statalist
Links
Software updates
Software archives
Customer service
Manuals & supplements
Stata Journal
STB
Stata News
Stata Automation
Plugins

Site overview
Products
Resources & support
Company
Site index

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