Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: merge with condition or vlookup with not-exact-match


From   "Sarah Kristina Reuter" <sarah.kristina.reuter@uni-jena.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: merge with condition or vlookup with not-exact-match
Date   Thu, 09 Sep 2010 14:07:17 +0200

Hi everyone,

I do not know if the following is possible in Stata, I hope anyone has an idea 
how to address it:

I want to merge 2 files, but the "ID"-variable is not unique in the sense that in 
the master file it is a point in time and in the using file it is a period of time 
defined as start-point of time and end-point of time. To illustrate the 
problem, let me give an example:

Master				Using
Point of Time	- V1		Starttime     - 	Endtime     - 	V2

What I need is: 
Point of Time - V1 - V2  if Point of Time >= Starttime & Point of Time <= 
Endtime

Something like 
merge Point of Time/master using Using if point of time in period of time, 
update
should do, just that I don't know how to build this command.

To me, it seems similar to the Excel-Function vlookup with not-exakt-match 
(the default-value of this function), which, if an exact match is not found,  
looks for the next largest value that is less than the key value. I've already 
tried the vlookup.ado but it seems to be an exact-match only.

Any ideas? Really looking forward to any recommendations!
Best regard
Sarah



-- 
Dipl.-Kffr. Sarah Reuter

Friedrich-Schiller-Universität Jena
Wirtschaftswissenschaftliche Fakultät
Lehrstuhl für Allgemeine Betriebswirtschaftslehre,
insbesondere Finanzierung, Banken und Risikomanagement
Carl-Zeiss-Str. 3
07743 Jena
Tel.: +49 (0)3641 9 43123
Fax: +49 (0)3641 9 43122



*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index