Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Weekday data and tsset

Subject   st: Weekday data and tsset
Date   Mon, 15 Aug 2005 16:06:18 +0200

Dear all,

I have a panel dataset which contains daily stock prices of 80 different firms
(variable: id). In order to calculate daily stock returns, it seems elegant to
tsset (something like tsset id Date) the dataset and to use Stata's
lag-operator (i.e. gen Return=Price/L.Price-1). However, as the dataset only
contains weekdays, the panel has gaps and the stock return over weekends
results to be missing when the lag-operator formula is applied. Of course, I
could calculate the daily returns by typing

sort id Date
by id (Date): gen double Return=Price[_n]/Price[_n-1]-1 if _n>1

But as calculating the returns like this is error prone in case of missing
values, I wonder if either there is a special (time-series) date format for
weekday data or if there is a simple way of transforming weekday data into
"daily" data.

Thanks a lot for looking into this matter.

Kind regards,

This message was sent using IMP, the Internet Messaging Program.

*   For searches and help try:

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