Statalist


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

Re: st: re: reshape command with dates


From   "Hugh Colaco" <[email protected]>
To   [email protected]
Subject   Re: st: re: reshape command with dates
Date   Fri, 31 Oct 2008 08:44:59 -0400

Thanks Kit. Works like a charm!!!

Hugh



On Thu, Oct 30, 2008 at 7:45 AM, Kit Baum <[email protected]> wrote:
> < >
> Hugh said
>
> I have a string variable (Id) with about 500 observations. I want to
> create a date sequence for each Id ranging from July 1, 2002 to Dec
> 31, 2006 as below:-
>
>
> I don't think you want to create 1,645 variables. Try
>
> clear
> set obs 1645
> // ssc inst tsmktim
> tsmktim dd, start(1jul2002)
> g long fmd = year(dd)*10000 + month(dd)*100 + day(dd)
> format fmd %9.0f
> g en = _n
> l in 1/10
> l in -10/l
>
> Save this as a Stata dataset, -expand- your existing file by 1645, and
> create a sequence number called -en- in the expanded file that goes
> 1,...,1645, 1,...,1645, etc. with -egen-.  Then you can -merge- the expanded
> file with the date sequence file, and you will have a file with IDs and
> dates in the YYYYMMDD format.
>
>
>
> Kit Baum, Boston College Economics and DIW Berlin
> http://ideas.repec.org/e/pba1.html
> An Introduction to Modern Econometrics Using Stata:
> http://www.stata-press.com/books/imeus.html
>
>
> *
> *   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/
>



-- 
Hugh
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index