Announcement

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

  • listing a unique values

    How to list unique values of variables with some condition. Let's say I want to see the unique observations of codes and descriptions that are not matched in my dataset after merging

  • #2
    Code:
    keep code description if _merge != 3
    duplicates drop
    list, noobs clean
    The above code destroys the data set. If you need to keep the data set intact, then -preserve- before running that code, and -restore- afterward.

    Comment


    • #3
      See also the groups command from the Stata Journal.

      Comment


      • #4
        A slight modification of #2 that does not destroy the dataset:

        Code:
        egen byte tag = tag(code description)
        list if tag & _merge!=3, noobs clean
        drop tag

        Comment


        • #5
          Originally posted by Hemanshu Kumar View Post
          A slight modification of #2 that does not destroy the dataset:

          Code:
          egen byte tag = tag(code description)
          list if tag & _merge!=3, noobs clean
          drop tag
          Can we extract this result in table format into excel or word?

          Comment


          • #6
            Please post a sample of the data using the -dataex- command.

            Comment

            Working...
            X