The key is in what can go as ... in
forval i = ... {
}
Your second solution is almost there:
forvalues i=2/4 {
forvalues j=1/`= nb_exam[`i']' {
dis nb_exam[`j']
}
}
A longer version might be clearer:
forvalues i=2/4 {
local J = nb_exam[`i']
forvalues j=1/`J' {
dis nb_exam[`j']
}
}
Nick
[email protected]
[email protected]
> I don't understand why this syntax is invalid
>
> forvalues i=2/4 {
> 2. forvalues j=1/nb_exam[`i'] {
> 3. dis nb_exam[`j']
> 4. }
> 5. }
> invalid syntax
>
> I have tried
>
> forvalues i=2/4 {
> 2. forvalues j=1/`nb_exam[`i']' {
> 3. dis nb_exam[`j']
> 4. }
> 5. }
> invalid syntax
>
> It's not better.
*
* 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/