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: Finding the corresponding variable


From   Ching Wong <ching.y.wong@student.adelaide.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   st: Finding the corresponding variable
Date   Sun, 7 Apr 2013 13:54:49 +0930

Hi,

I have TWO variables of dates, called "datea" and "dateb". I would
like to calculate the number of days between a particular date (says,
1/01/2013) and the closest day either "datea" or "dateb".

Firstly, I generated one variable called "var1" which is the number of
days between the particular date and "datea" and also generated
another variable called "var2" which is the number of days between the
particular date and "dateb".

Then I set up another variable "var3" in order to choose the minimun
number of days between "var1" and "var2". By using the Command as
following:
---> egen var3 = rowmin (var1 var2).

My question is that after getting "var3", how I can list the
corresponding "datea" or "dateb"?
i.e. var3---> var1 or var2----> datea or dateb

Thank you for your time.

Best regards,

Wong
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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