Announcement

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

  • Getting unique words from a macro

    I have a local macro with a list of words, I would like to filter it so I can get only unique words.

    Code:
    local mylist variableA variableA variableA variableB variableB
    do something to `mylist'
    di "`mylist'"
    variableA variableB
    Kind regards,
    Konrad
    Version: Stata/IC 13.1

  • #2
    Code:
    local mylist variableA variableA variableA variableB variableB
    local uniqlist : list uniq mylist
    
    mac li
    <stuff omitted> 
    _uniqlist:      variableA variableB
    _mylist:        variableA variableA variableA variableB variableB
    Big tip: For tools like this, start with help macro.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Big tip: For tools like this, start with help macro.
      Thanks for the code, it worked like a charm. With respect to this help section, I did have a look but I find it rather synoptic.
      Last edited by Konrad Zdeb; 29 Aug 2014, 10:17. Reason: Spelling.
      Kind regards,
      Konrad
      Version: Stata/IC 13.1

      Comment


      • #4
        You have to keep clicking to dig deeper with the macro help.
        help macrolists will get you to info on the trick Nick used here.
        Most of what I routinely use with macros is summarized well if you click on the extended_fcn link in the main macro help. To get to this you have to click one more time to get to the full information on manipulating lists.

        Comment

        Working...
        X