Bookmark and Share

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


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

st: Looping Variable Labels Define


From   Beatrice Benavidez <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index