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.
I think this isn't a scope problem, but a local macro naming issue. I
think you need to modify the way you get and use the -tempfiles-.