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

From |
Nick Winter <nw53@cornell.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Limit of numlist |

Date |
Thu, 06 Oct 2005 10:39:24 -0400 |

This doesn't speak to the numlist limit question, but your code could simply use -forvalues- rather than -foreach ... numlist-.

There is no reason to have Stata create and store the numlist, rather than simply iterate through the values from 1 to N.

Your code could be:

forvalues i = 1/`l' {

...

}

Or even better,

forvalues i = 1/`=_N' {

...

}

That is, you can skip the -count- and just have Stata evaluate the macro expression `=_N'.

--Nick WInter

At 09:56 AM 10/6/2005, you wrote:

________________________________________________________I am trying to writre formatted text output from a Stata data file and wrote a program based on the examples in the Stat manual and the UCLA Web site (http://www.ats.ucla.edu/stat/stata/faq/outform.htm). Some of the code is shown below. I am getting an error "invalid numlist has too many elements r(123)". I have 17,915 observations. If I limit my dataset to a smaller number of observations (using drop or keep) to, say 1,000, or hardwire a smaller number, the program sucessfully writes out the data. After searching the documentation I cannot find a limit to the number stored in numlist. Is there such a limit? If so, can it be increased? TIA, Alan *** Stata Code Follows *** quietly count; local l = r(N); foreach i of numlist 1/`l'{; file write temp _col(1) %5.0f (frm_id1[`i']) _col(8) %5.0f (co_id1[`i']) _col(14) %9.1f (est_rnd_amt_fund[`i']) _newline; }; * * 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/

Nicholas J. G. Winter 607.255.8819 t

Assistant Professor 607.255.4530 f

Department of Government nw53@cornell.edu e

Cornell University falcon.arts.cornell.edu/nw53 w

308 White Hall

Ithaca, NY 14853-4601

*

* 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/

**Follow-Ups**:**Re: st: Limit of numlist***From:*Alan Neustadtl <alan.neustadtl@gmail.com>

**References**:**st: Limit of numlist***From:*Alan Neustadtl <alan.neustadtl@gmail.com>

- Prev by Date:
**st: Plain text Messages on Statalist** - Next by Date:
**Re: st: Limit of numlist** - Previous by thread:
**st: Limit of numlist** - Next by thread:
**Re: st: Limit of numlist** - Index(es):

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