[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Sergiy Radyakin" <serjradyakin@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: identifying observations in one variable that appear in another variable |

Date |
Thu, 30 Aug 2007 15:27:23 -0400 |

Well, this code checks if a particular value (e.g. "Volvo 260") is among the values of a particular variable (make). You can cycle through your second variable to get those candidate values. If I understand you correctly you have a dataset like this: var1 var2 alpha kappa beta beta gamma sigma delta delta And you want the values of var2, which are in your var1: (beta and delta). **------------------------------------- use mydata keep var1 rename var sort var save file1 use mydata keep var2 rename var2 var sort var merge var using file1 tab _merge help merge **------------------------------------- See the interpretation of the _merge variable Best regards, Sergiy Radyakin On 8/30/07, Dalhia <ggs_da@yahoo.com> wrote: > Hi, thanks for the response. Just to make sure I > understand (I'm not very familiar with stata code) - > does this code basically check if particular values of > one variable exist in another variable? Or does it > check all observations in one variable against another > variable? I have 9544 observations so the former > technique will be difficult. > > thanks > dalhia > --- Sergiy Radyakin <serjradyakin@gmail.com> wrote: > > > There is a multiple way of doing it, but see -help > > merge- if you are > > building some sort of relational DB. (will work > > similar to linking > > tables in Access). > > > > If you have a single dataset, then -levelsof- gives > > you the distinct > > values of a variable. You can test for each value of > > one variable if > > it occurs in another. See -help levelsof- and -help > > macro-. > > > > sysuse auto > > levelsof make, local(m) > > local v=`"`"Volvo 260"'"' > > di `: list v in m' > > local v=`"`"Volvo S70"'"' > > di `: list v in m' > > > > Regards, Sergiy > > > > On 8/29/07, Dalhia <ggs_da@yahoo.com> wrote: > > > hi, I am trying to figure out a way to identify > > all > > > observations in one variable that also appear in > > > another variable. I have two variables - > > shareholder > > > name and company name and I'm trying to find all > > the > > > shareholders who are also on my list of companies. > > Is > > > there a way to do this in Stata? > > > > > > Thanks so much for your help on this. I appreciate > > it. > > > > > > Dalhia Mani > > > > > > > > > > > > > > > ____________________________________________________________________________________ > > > Got a little couch potato? > > > Check out fun summer activities for kids. > > > > > > http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz > > > * > > > * For searches and help try: > > > * > > http://www.stata.com/support/faqs/res/findit.html > > > * http://www.stata.com/support/statalist/faq > > > * http://www.ats.ucla.edu/stat/stata/ > > > > > * > > * For searches and help try: > > * > > http://www.stata.com/support/faqs/res/findit.html > > * http://www.stata.com/support/statalist/faq > > * http://www.ats.ucla.edu/stat/stata/ > > > > > > > ____________________________________________________________________________________ > Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. > http://answers.yahoo.com/dir/?link=list&sid=396545433 > * > * For searches and help try: > * http://www.stata.com/support/faqs/res/findit.html > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**Re: st: identifying observations in one variable that appear in another variable***From:*"Sergiy Radyakin" <serjradyakin@gmail.com>

**Re: st: identifying observations in one variable that appear in another variable***From:*Dalhia <ggs_da@yahoo.com>

- Prev by Date:
**st: Stata 9 dialog problem with .iseq()** - Next by Date:
**Re: st: regressing on percentages.** - Previous by thread:
**Re: st: identifying observations in one variable that appear in another variable** - Next by thread:
**st: RE: identifying observations in one variable that appear in another variable** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |