Announcement

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

  • Group String variables together

    Is it possible to group all String variables in the dataset together. I created this code, but it doesn't do what I want.

    foreach v of varlist _all{
    capture confirm string `v'
    if _rc{
    order `v', first
    }
    }

    I want all the string variables to be put to the front of the dataset.

  • #2
    Your approach doesn't work because the return code will be 0 if the variable is string. Your code does the opposite, sort the numeric variables to first.

    Alternatively,

    Code:
    ds, has(type string)
    order `r(varlist)'

    Comment

    Working...
    X