Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Jeremy A. Grey" <jagrey@umn.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Merge by range of values |

Date |
Mon, 13 Jun 2011 16:49:42 -0500 |

Hi everyone, I am trying to find a way to merge data sets according to a range of values, sort of a combination of m:1 merge and inrange(). In one data set, each observation represents a subject with the individual's value for variable X. In another data set, each observation represents a range of values for variable X. The start and end values of the range are separate variables, such as start_X and end_X. The remaining variables contain the values of Y and Z for all values of X within that range. Is there a way to merge the Y and Z data from the second data set into the first by comparing the value of X to the range specified by start_X and end_X? I thought of transforming the second data set in order to create new variables, such as start_X_1, end_X_1, Y_1, Z_1, start_X_2, end_X_2, Y_2, Z_2, etc., adding those data to each observation in the first dataset, and using a loop and inrange() in order to compute Y and Z for each subject, but there are about 3,000,000 different ranges of X in the second data set, so this is impractical. Thank you in advance for your help. Jeremy -- Jeremy A. Grey, MA Doctoral Student Division of Epidemiology and Community Health University of Minnesota School of Public Health * * 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/

**Follow-Ups**:**Re: st: Merge by range of values***From:*Phil Schumm <pschumm@uchicago.edu>

- Prev by Date:
**st: stcoxkm command for testing PH assumption** - Next by Date:
**st: Different types of missing data and MI** - Previous by thread:
**st: stcoxkm command for testing PH assumption** - Next by thread:
**Re: st: Merge by range of values** - Index(es):