Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • locals and varnames

    Dear all,
    say that i want to create new variables using a numlist as follows:
    Code:
    forvalues i=5(5)15 {
    *Im using normal just as a simple example
    gen g`i'=rnormal()
    }
    With this code I create variables named g5 g10 g15
    Is there anyway i can modify the above code, so that i can creates variables as: g05 g10 g15 ?
    Specifically, i need to add the zero whenever the value of i is between 1 and 9.
    Thank you.
    Fernando

  • #2
    Search this forum or Stata Journal archives for a Tip on
    looping over non-integers.

    Comment


    • #3
      Thank you Nick! that is exactly what i needed.

      Comment

      Working...
      X