Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Calculating returns between 2 dates using 2 files


From   "Hugh Colaco" <[email protected]>
To   statalist <[email protected]>
Subject   st: Calculating returns between 2 dates using 2 files
Date   Mon, 24 Apr 2006 16:36:55 -0400

Hi Statalist,

I have 2 files; one with dates and returns on each date (i.e. File 1)
and the second, two given dates for each observation. The dates run
from 1990 to 2004.

I want to calculate "DateRet" (i.e. the return between the two dates
in file 2) for each obs. I have approx 1000 obs. Note from the example
that Date2 return is not considered (i.e. the last return considered
is the date prior to Date2).

Thanks,

Hugh



File1

Date	Return
1/2/1990	0.003
1/3/1990	0.006
1/4/1990	-0.004
1/5/1990	0.001
1/8/1990	0.002
1/9/1990	-0.001
1/10/1990	-0.005
1/11/1990	0.002
1/12/1990	-0.015
1/15/1990	-0.005
1/16/1990	-0.001
1/17/1990	0.001
1/18/1990	-0.003
1/19/1990	0.005
1/22/1990	-0.011
1/23/1990	-0.002
1/24/1990	-0.011
1/25/1990	-0.001
1/26/1990	-0.005
1/29/1990	-0.006
1/30/1990	-0.011
1/31/1990	0.007
2/1/1990	0.003
2/2/1990	0.007
2/5/1990	0.004
2/6/1990	0.001
2/7/1990	0.006
2/8/1990	0.002
2/9/1990	0.004




File2

Obs       Date1	Date2	                           DateRet
1          1/31/1990	2/2/1990	                (1+0.007)*(1+0.003)-1
2         1/3/1990	1/8/1990	                 (1+0.006)*(1-0.004)*(1+0.001)-1

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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