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 on April 23, and its replacement, is already up and running.

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

st: How to generate a time variable and merge with another file

From   李 梦佳 <>
To   "" <>
Subject   st: How to generate a time variable and merge with another file
Date   Thu, 18 Apr 2013 23:14:13 +0800

Dear Statalist,

I have data in the following structure and wish to add a column with inputting the months

Current data:
Fund		Stockholding	Reporttime
000011.OF	000001		200506	
000011.OF      000002		200506	
660001.OF	600002		201012

For each Reporttime (semi-annual), I wish to merge from another dta. with its past 36 monthly returns, to make this  like the following:

Fund		Stockholding	Reporttime	Month	Return
000011.OF	000001		200506	       2005-06		r1
000011.OF	000001		200506	       2005-05		r2
000011.OF	000001		200506	       2002-07	        rn
660001.OF	000002		201012		2008-01           rx

Now I have used "expand 36" to create 36 lines for each stock at each reporttime. How can I generate the last column "Month" and further using the stockholding (code) and Month as the link to merge the other file with returns data?

Many thanks and best regards,

*   For searches and help try:

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