Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: tempfile & scope


From   "Danielle H. Ferry" <[email protected]>
To   StataList <[email protected]>
Subject   st: tempfile & scope
Date   Wed, 24 Sep 2003 19:14:57 -0400

Hi,

Suppose I want to create 2 temporary datasets inside a -forval- loop, with
names indexed by the loop number (i.e., `results0', `results1'). Once I get
outside the loop, I want to append them using -dsconcat-, but since I
defined them inside the loop, they no longer exist.

A more concrete example:

forval k = 0(1)1 {

    tempname memhold
    tempfile results

    postfile `memhold' var1 var2 var3 using `results'`k', replace

    forval y = 1998(1)2002 {
        ...

        post `memhold' (`x') (`y') (`z')
    }

    postclose `memhold'
}

dsconcat `results0' `results1'

Could someone offer a suggestion on how to do this, please? Much thanks.

-- 
Danielle H. Ferry
National Bureau of Economic Research
365 Fifth Avenue, 5th Floor
New York, NY 10016
*
*   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