Statalist The Stata Listserver


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

RE: st: RE: splitting a list


From   "Rajesh Tharyan" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: splitting a list
Date   Sun, 22 Oct 2006 17:30:53 +0100

Thanks, I guess using official command is the best. Following your examples
I did one on my own. Still using savesome though. 
 
forvalues i=500 1000 to 5000 {
local a=`i'- 499
savesome x in `a'/`i' using "somepath\list`a'to`i'"
}

rajesh

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of jean ries
Sent: 20 October 2006 16:26
To: [email protected]
Subject: Re: st: RE: splitting a list

Here is a solution that uses only official Stata commands:

forvalues f = 1/10 {
	preserve
	keep if inrange(_n, (`f'-1)*500 + 1, `f'*500)
	save file_`f'
	restore
}


On 10/20/06, Nick Cox <[email protected]> wrote:
> -savesome- is one way to do it. -savesome-
> is not awesome, but it will do.
>
> You can do everything in one loop. For example,
>
> forval i = 1/10 {
>         local first = 1 + 500 * (`i' - 1)
>         local last = `first' + 499
>         savesome var in `first'/`last' using file`i'
> }
>
> Nick
> [email protected]
>
> Rajesh Tharyan
>
> > I have a file with one variable and 5000 observations. Is
> > there a way to
> > create say 10 different files with 500 observations in each
> > and serially
> > number them . i.e the first file would contain obs 1/500, the
> > next file
> > would contain 501/1000 observations and so on.
> >
> > One option I had in mind was use savesome (a user written ado)
> >
> > For example
> >
> > savesome var in 1/500 using file1.dta
> >
> > but I am not sure how to automate the process..
>
*
*   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/



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