Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Returning Labels based on values.

From   "Cook, Daniel E" <>
To   "" <>
Subject   st: Returning Labels based on values.
Date   Tue, 25 Oct 2011 15:36:22 +0000

For programming purposes, I'm wondering if there is a way to return the a label based on the value used to specify it.

For example, consider a data set with the following values and labels for the variable SEASON:

1 Winter
2 Spring
3 Summer
4 Fall

Now suppose I have a do file and I want to create a graph for the mean temperature of each I write something like this:

foreach v of numlist 1/4 {

...create a graph if SEASON == `v'... of avg. temp.


Now - I want to label each graph using the value label of the season being specified. In other words, if the graph is for the Summer - I'd like to add the value label "Summer" as the title, caption, or perhaps within the filename. So I'm looking for something like this:

foreach v of numlist 1/4 {

local name getvaluelabel(`v', SEASON) //This function would return the label for a given value by specifying the variable or value label.

...create a graph if SEASON == `v'...title(`name')


I have looked everywhere for a way to do this but can't seem to find anything. Perhaps I am overlooking something.


Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index