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: Dynamically generating values based on description of other variables


From   Veeresh Thummadi <[email protected]>
To   [email protected]
Subject   st: Dynamically generating values based on description of other variables
Date   Thu, 30 Jan 2014 12:05:51 -0500

Hi

I want to create new variables of cities(and its values) based on the
existing description of countries by tourists. For instance I have
values for Countries (var1) as 'USA' 'Germany' 'Spain' etc. I want to
create new variables of cities-like manhattan(var3), columbus(var4)
based on Countries(var1) and description encoded in var2. So
'description'(var2) will have values like ' manhattan is a vibrant
city' or ' etc. So I need to create a for-loop of variables for
dynamically generating variables and values like
manhattan,chicago,columbus (say all the cities in the world). So if a
person mentions manhattan in his description then the new variable
'manhattan' dynamically created should have a value 1(0 if not visited
manhattan). I have tried this code but it has not been working:

foreach y of global Countries {
                    gen y=0
replace y=1 if (strmatch(description,"*y*"))

Thanks
Veeresh


Veeresh Thummadi
Research scientist
Stern School of business
New York University
*
*   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