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

st: Is a "merge, if" possible?

From   "Polis, Chelsea B." <>
To   "" <>
Subject   st: Is a "merge, if" possible?
Date   Tue, 20 Oct 2009 17:47:18 -0400

Dear Statalisters,

I have a dataset with three variables: study_id, avgvl (average viral load), and lastneground (last survey round at which a person was seronegative, ranging from 1 to 10).

I also have 10 datasets containing successive rounds of yearly survey information.  I want to link information on individuals at their last seronegative round to look at the effect of specific variables prior to seroconversion on average viral load.

So, from within the dataset with three variables, I want to write something like:
merge study_id using "C:\Round 1.dta", if lastneground==1
merge study_id using "C:\Round 2.dta", if lastneground==2
and so on through round 10.

But, merge doesn't seem to be able to be combined with an if statement.  Are there any elegant ways of doing this, or must I do it piecemeal (creating what I need in 10 separate datasets and appending)?

Chelsea B. Polis, PhD
Department of Population, Family and Reproductive Health
Johns Hopkins Bloomberg School of Public Health

*   For searches and help try:

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