Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: syntax error in forvalues range definition using a tempvar??


From   "Brian R. Sala" <[email protected]>
To   [email protected]
Subject   st: syntax error in forvalues range definition using a tempvar??
Date   Sat, 16 Jul 2005 17:00:38 -0700

Can someone enlighten me on this syntax error, please.

why does this fail:

. tempvar maxn

. egen byte `maxn' = max(assignment_count)

. tab `maxn'

__000001 | Freq. Percent Cum.
------------+-----------------------------------
4 | 20,299 100.00 100.00
------------+-----------------------------------
Total | 20,299 100.00

. forvalues i = 1/`maxn' {
2. di `i'
3. }
invalid syntax
r(198);


clearly, `maxn' has a value. Superficially, this looks equivalent to the syntax shown in the STATA 8 programming manual (pp. 206-207).

yet when I do this:

. tempvar max_assignments
. egen byte `max_assignments' = max(assignment_count)
. local maxn = `max_assignments'
. forvalues i = 1/`maxn' {
2. display `i'
3. }
1
2
3
4

thanks for any help.
--
Brian R. Sala [email protected]
Dept. of Political Science 530 752-0977 (o)
UC-Davis 530 752-8666 (fax)
One Shields Avenue
Davis CA 95616-8682
----------------------------------------------
Beer is proof that God loves us and wants us
to be happy. --Benjamin Franklin

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