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

st: RE: Is a "merge, if" possible?

From   "Nick Cox" <>
To   <>
Subject   st: RE: Is a "merge, if" possible?
Date   Tue, 20 Oct 2009 22:58:26 +0100

The help for -merge- would tell you if -if- were allowed, and it is not.

If it were, it would not be an option and it would not therefore follow
a comma. 

If you want only part of a dataset to take part, the natural thing would
seem to be to -drop- the part that is not required, or equivalently
-keep- the part that is required, before any merging. 

However, as you say, your problem sounds like an -append- problem any
way, at least in the first instance. 

-append- can readily combine several datasets, unless you are not in
Stata 11, in which case you should have told us that. 


Polis, Chelsea B.

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)?

*   For searches and help try:

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