Thanks for your help Nick ; append has done the trick.
Victor
----- Original Message -----
From: Nick Cox <[email protected]>
To: <[email protected]>
Sent: Friday, March 05, 2004 10:59 AM
Subject: st: RE: Re: Preparing for merge
> First, let's rewrite that more concisely:
>
> forval a = 1/4 {
> forval b = 1/4 {
> forval c = 1/4 {
> forval d = 1/4 {
> clear
> set obs 1
> gen a = `a'
> gen b = `b'
> gen c = `c'
> gen d = `d'
> save a`a'b`b'c`c'd`d',replace
> }
> }
> }
> }
>
> Then it looks as if you should go
>
> local i = 0
> forval a = 1/4 {
> forval b = 1/4 {
> forval c = 1/4 {
> forval d = 1/4 {
> clear
> set obs 1
> gen a = `a'
> gen b = `b'
> gen c = `c'
> gen d = `d'
> save a`++i',replace
> }
> }
> }
> }
>
> If your Stata is <= 6, you can still use the
> same basic technique by
>
> local i = 0
> ...
> local i = `i' + 1
> save a`i', replace
> ...
>
>
> That way, your datasets are a1.dta, ..., a256.dta.
>
> But I don't understand why you want to -merge- these
> datasets. Do you mean -append-?
>
> Also, if this is the real problem, you could do
> it all in place with -egen, seq()-.
>
> Nick
> [email protected]
>
> victor michael zammit
>
> > the following program generates 256 ,1 by 4 datasets.
> > Can someone tell me how I could number (in order) these datasets,
> > such that I could then use merge and bring them in 1, 256 by 4
> > dataset ?
> > local a = 1
> > while `a'<= 4 {
> > local b = 1
> > while `b' <= 4 {
> > local c = 1
> > while `c' <= 4 {
> > local d = 1
> > while `d' <= 4 {
> > clear
> > set obs 1
> > gen a = `a'
> > gen b = `b'
> > gen c = `c'
> > gen d = `d'
> > save a`a'b`b'c`c'd`d',replace
> > local d = `d' + 1
> > }
> > local c = `c' + 1
> > }
> > local b = `b' + 1
> > }
> > local a = `a' + 1
> > }
>
> *
> * 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/