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: Checking if one variable = any of the values of another

From   Maria Davydenko <>
Subject   st: Checking if one variable = any of the values of another
Date   Wed, 7 Dec 2011 19:17:25 -0500

Hey all,

I have a Twitter data set where each observation includes the user who
tweeted (var from_user), what they tweeted (var text) as well as
variables m1 through m11 (up to 11 users they mentioned in var text).
I want to create an indicator variable grpment that =1 if any of the m
(match) variables for a given observation are equal to any of the
other values of from_user.  Here's what it looks like:

from_user	text		m1	m2 …11	grpment
P1		@P2		P2			1
P2		@other				        0
P3		@P1 @P2	P1	P2		1

In human speak, I want to see if the from_user is mentioning any of
the other from_users, based on the 11 different m variables.

I have it all figured out except the grpment element.  So far, I've
been playing with loops but can't think of anything short of a giant
macro that could make this work. If you have any insight, it would be
much appreciated!



*   For searches and help try:

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