Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Looping Variable Labels Define


From   Beatrice Benavidez <beatricestata1711@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Looping Variable Labels Define
Date   Tue, 19 Feb 2013 11:47:12 +0400

Hi everyone,

I generated value labels for variables code_outlet and code_topic -
code_outlet: 1 "Restaurant"     2 "Lounge" 3 "Bar" 4 "Minibar" 5 "Room Service"

code_topic: 1 "Breakfast" 2 "Lunch" 3 "Afternoon Tea" 4 "Dinner" 5
"Night" 6 "Minibar"

I loop the creation of code_outlet_topic which is an amalgamation of
code_outlet and code_topic-

generate code_outlet_topic=.

forvalues o=1/5{

forvalues to=1/6{

replace code_outlet_topic=`o'`to'0 if ( code_outlet==`o' | code_topic==`to')

}

}



I would like to then have labels for code_outlet_topic such as:

label define code_outlet topic 110 "Restaurant - Breakfast" 120
"Restaurant - Lunch" ... 550 "Room Service - Night

Would there be a way to do label the variable without having to do
them one by one as it is composed purely of other variable labels and
a dash?



Thank you!
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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