Announcement

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

  • how to do _all except a few certain variables

    i want to use the "foreach var of varlist all" command to do functions to every variable except three variables i have

  • #2
    Then skip those three variables:

    Code:
    foreach var of varlist _all {
        if inlist("`var'", "skip_var1", "skip_var2", "skip_var3") {
            continue
        }
        ...
    }
    where skip_var indicates the names of the variables you want to skip.

    Comment


    • #3
      While Daniel's solution is short and clear, I've had related situations in which manipulating the too-inclusive variable list with various macro functions is useful, such as:
      Code:
      unab MyVarList: _all
      local droplist = "var1 var2 var3"
      local MyVarList: list MyVarList - droplist

      Comment


      • #4
        Thank you!

        Comment

        Working...
        X