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]

From |
Richard Warr <rswarr@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: how can I merge two data sets over a range of values |

Date |
Thu, 9 Feb 2012 12:09:14 -0500 |

I''ve done more research and this is basically something that SAS PROC SQL can deal with - basically merge if a value falls within a range of values. Append could work but would require a lot of cleaning up afterwards. I know that I won't get a 1:1 match, but that's OK as I will then pick the best match later. On Thu, Feb 9, 2012 at 11:16 AM, Nick Cox <njcoxstata@gmail.com> wrote: > Can you explain why this is not an -append- problem, that is, precisely why > you want matching or pairing and in what sense you expect 1:1 matching or > pairing to be possible anyway? > > Nick > > > > On 9 Feb 2012, at 15:01, Richard Warr <rswarr@gmail.com> wrote: > >> Thanks, but I am not sure that will work as my variables are >> continuous. Both the dataset1 variable and the dataset2 variables can >> vary up to 3 decimal places. In each case I want to merge them if >> they are basically close to each other even if they aren't exactly >> alike. So something like merge x with y(+/- 0.5) is what I am >> looking for. >> >> Here is just a snippet of the data >> 15.9375 >> 20.6 >> 39.53 >> 40.85 >> 65.31 >> 62.538 >> 7.969 >> 10.875 >> 10.3 >> 9.625 >> 19.765 >> 20.425 >> 34.82 >> 31.1 >> 29.78 >> 7.969 >> 19.765 >> >> >> In each case I want to be able to set a level of precision for the >> merge and allow a merge even if the variable isn't exactly the same. >> Perhaps it can't be done! >> >> >> >> >> >> >> >> On Wednesday, February 8, 2012, Lim Lee <lee.haklim@gmail.com> wrote: >>> >>> you can create a variable "x" tagging all price==20 in dataset1 and >>> variable "x" tagging all price in the range of 19.5 to 20.5. If you >>> have more than one value with price=20 your going to have to make that >>> each observation unique or drop one since merging m:m makes little >>> sense and the merging process requires at least one dataset to be >>> uniquely identified with regard to the variable your are matching the >>> datasets with. >>> >>> hope this might be of help. >>> >>> Lim >>> >>> On Wed, Feb 8, 2012 at 4:45 PM, Richard Warr <rswarr@gmail.com> wrote: >>>> >>>> Hi, I want to merge two data sets. The merge variable is the stock >>>> price. However I would like to merge over a range of prices. For >>>> example if the price is 20 in dataset1, I would like that to merge >>>> with any price in the range of 19.5 to 20.5 in dataset2. Currently >>>> my data sets each contain only a single stock price series (and other >>>> variables). >>>> >>>> >>>> >>> > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: how can I merge two data sets over a range of values***From:*Richard Warr <rswarr@gmail.com>

**Re: st: how can I merge two data sets over a range of values***From:*Lim Lee <lee.haklim@gmail.com>

**Re: st: how can I merge two data sets over a range of values***From:*Richard Warr <rswarr@gmail.com>

**Re: st: how can I merge two data sets over a range of values***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**st: Bai and Perron test** - Next by Date:
**Re: st: Matching procedure based on shortest distance given latitudes and longitudes** - Previous by thread:
**Re: st: how can I merge two data sets over a range of values** - Next by thread:
**Re: st: how can I merge two data sets over a range of values** - Index(es):