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: matching observations across variables
From
Yogesh Uppal <[email protected]>
To
[email protected]
Subject
st: matching observations across variables
Date
Fri, 28 Jun 2013 20:46:05 -0400
Hi Statalisters,
I have a problem that I am not sure how to solve. I have data of the
following form:
input str2 state city neighboring_city1 neighboring_city2
neighboring_city3 outcome neighbor
"A" 1 3 4 5 1 .
"A" 2 1 4 5 1 .
"A" 3 1 5 6 0 1
"A" 4 1 2 . 0 1
"A" 5 1 2 3 0 1
"A" 6 5 4 . 0 0
end
neighboring_city1, neighboring_city2, and neighboring_city3 identify
all the neighboring cities of cities in the variable "city". outcome
is some variable I am interested in. This is how I have set up the
data so far. I want to create a variable called "neighbor" that is 1
for all cities that have 0 as outcome and are a neighbor to a city
with 1 as outcome. For example, the neighbor variable I created here
is 1 for city 3 because it is neighbor to city 1. However, city 6 is 0
because it is not a neighbor to a city that has 1 as outcome.
I hope I laid out the problem clearly. I would appreciate it if anyone
can suggest a solution.
thanks in advance,
Yogesh
*
* 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/