Quoting downstream values ​​in Stata using forvalues

So this works as expected:

. forvalues i = 1(1)3 {
  2. di `i'
  3. }

      

1
  2
  3

And it is not:

. forvalues i = 3(1)1 {
  2. di `i'
  3. }
           <--- that an empty line that returns from the above loop.

      

If I want to create

3
2
1

      

Do I really need this to be explored?

. forvalues i = 1(1)3 {
  2. di 3+1-`i'
  3. }

      

Why?

+3


source to share


1 answer


Your cycle should begin

forv i = 3(-1)1 

      



since your step is -1

not 1

.

+5


source







All Articles