Announcement

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

  • lexicographical sorting of strings

    Hi,

    I have a string variable called "name". For this variable, each observation contains several words (for example: John Anthony Smith). I would like to order the words of each observation according to the lexicographical order (for example: John Anthony Smith becomes Anthony John Smith).

    The only solution I have found is to separate each word of the string into a specific variable, do a reshape (wide to long), do a sort, and reshape from large to wide. On big data set it takes a lot of time. Is there a fastest way?

    Thank you very much!

    Antoine

  • #2
    In principle rowsort (Stata Journal) can do this differently. I make no promises about speed with a very large dataset.

    Comment

    Working...
    X