Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | 李 梦佳 <limengjia626@163.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
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, Amy * * 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/