[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"victor michael zammit" <vmz@vol.net.mt> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Re: RE: Re: Preparing for merge |

Date |
Thu, 4 Mar 2004 14:58:44 +0100 |

Thanks for your help Nick ; append has done the trick. Victor ----- Original Message ----- From: Nick Cox <n.j.cox@durham.ac.uk> To: <statalist@hsphsun2.harvard.edu> 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 > n.j.cox@durham.ac.uk > > 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/

**References**:**st: RE: Re: Preparing for merge***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**RE: st: Test of coefficient equality** - Next by Date:
**RE: st: Test of coefficient equality** - Previous by thread:
**st: RE: Re: Preparing for merge** - Next by thread:
**st: annoying boss** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |