Announcement

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

  • Referring to a list of variables in functions

    Hello everyone
    Just wondering if there is an easy way to refer to a group of many variables in functions such as max, min, etc. For example, when doing:

    gen my_var = max(a1, a2, a3, ..., a9)

    Is there any shortcut such as

    gen my_var = max(a?)

    so that I don't need to type all variables in the arguments for the function max() when all arguments are variables named in the fashion "a?".

    Thank you very much.

  • #2
    Code:
    unab vbles: a?
    local vbles: subinstr local vbles " " ", ", all
    gen new = max(`vbles')
    will do it, but unless your list of variables is really long, it's probably easier to just list them out.

    Comment


    • #3
      Thank you very much Clyde.

      Comment

      Working...
      X