Thank you very much! The code works perfectly - and now I know I can
also do -set obs- in Stata, just like in other programs. I really
appreciate your help.
Mingfeng
On Thu, Jun 19, 2008 at 10:48 AM, Maarten buis <[email protected]> wrote:
> --- Mingfeng Lin <[email protected]> wrote:
>> Is there a way to create new rows and then fill in weekend dates
>> automatically in Stata? For instance, I have a series of stock
>> prices, and Jan01-Jan05 are Monday-Friday, and weekend dates are not
>> available.
>>
>> What I want to do is to "insert rows", say Jan06 and Jan07, such that
>> they take on the value of Jan05. The only way I can think of is to
>> create this series of dates in Excel, then import to Stata and merge
>> it, and then use [_n-1] to replace the missing values. But is there
>> a more straightforward way? I have a bunch of these files with
>> different date ranges and it's really inefficient.
>
> *------------- begin example ----------------
> tempfile a b
> sysuse sp500, clear
> sort date
> save `a'
>
> sum date, meanonly
> local min = r(min)
> local days = r(max) - r(min) + 1
>
> drop _all
> set obs `days'
> gen date = _n + `min' - 1
> sort date
> save `b'
>
> merge date using `a'
> format date %td
> *-------------- end example ---------------
> (For more on how to use examples I sent to the Statalist, see
> http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
>
> Hope this helps,
> Maarten
>
>
> -----------------------------------------
> Maarten L. Buis
> Department of Social Research Methodology
> Vrije Universiteit Amsterdam
> Boelelaan 1081
> 1081 HV Amsterdam
> The Netherlands
>
> visiting address:
> Buitenveldertselaan 3 (Metropolitan), room Z434
>
> +31 20 5986715
>
> http://home.fsw.vu.nl/m.buis/
> -----------------------------------------
>
>
> __________________________________________________________
> Sent from Yahoo! Mail.
> A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
> *
> * 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/
>
*
* 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/