Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: How to Match Observations Over Different Date variables


From   Muhammad Anees <[email protected]>
To   [email protected]
Subject   st: How to Match Observations Over Different Date variables
Date   Wed, 17 Aug 2011 10:30:43 +0500

Dear Listers!

I have been working on stock prices of different firms from Jan 1,
2005 to October 30, 2010. The problem I face is that every stock price
is obtained and is listed with somewhat different date variables and
all the date variables are not axactly matching. I need to analyse
stock prices after matching them over dates. I know how to format the
date variables in Stata with the Help of Nick and others after a
discussion on this list, but even working for weeks, I could not
figure out how to match the stock prices over a similar date index.

My example of data looks like below:

Date1          Stock1          Date 2          Stock2
Jan1,2005    40                 Jan1,2005     30
Jan2,2005    40                 Jan2,2005     30
Jan3,2005    40                 Jan3,2005     30
Jan4,2005    40                 Jan4,2005     30
Jan5,2005    40                 Jan8,2005     30
Jan8,2005    40                 Jan9,2005     30
Jan9,2005    40                 Jan11,2005     30
Jan10,2005    40                 Jan12,2005     30
Jan11,2005    40                 Jan13,2005     30
Jan12,2005    40                 Jan14,2005     30
and so till last date on the date1 variable.

Now what I want is to have the data like

Date1          Stock1          Date 2          Stock2
Jan1,2005    40                 Jan1,2005     30
Jan2,2005    40                 Jan2,2005     30
Jan3,2005    40                 Jan3,2005     30
Jan4,2005    40                 Jan4,2005     30
Jan5,2005    40                 .                     .
jan6,2005      40                .                      .
.                       .                  .                      .
.                       .                  .                      .
Jan9,2005    40                 Jan9,2005     30
Jan10,2005    40                 .                     .
Jan11,2005    40                 Jan112005     30
Jan12,2005    40                 Jan122005     30
and so on.

Now my new data should look like above. What I need is to have a
missing value for date2 and stock2 if it has missing stock data on a
date where date1 and stock1 has a stock data. It further implies both
the stocks should be arranges on a single data variable if stock1 is
present and stock is not, stock2 should treated is missing. It is
evident that if both stocks are missing then it would not be a real
problem is both have missing date. My real problem is that I could not
arrange the the stocks over a single date variable.
I would be thankful to your suggestion and guidance.

Regards

Muhammad Anees
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index