Announcement

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

  • inlist with many variables

    Hello.

    I have 100 numeric variables (var1-var100) which are all categorical (1, 2, 3). I would like to identify the observations with any variable equal to 3.
    Is there any simple function that can do that? I tried browse if inlist(3,var1-var100), but it doesn't work.

    Thank you very much.

  • #2
    -inlist- does not recognize varlists which is why your code "doesn't work" (please read the FAQ which explains why this type of statement is not useful)

    instead try this:
    Code:
    egen newvar=anymatch(var1-var100), v(3)
    see
    Code:
    help egen
    for more

    Comment


    • #3
      Originally posted by Rich Goldstein View Post
      -inlist- does not recognize varlists which is why your code "doesn't work" (please read the FAQ which explains why this type of statement is not useful)

      instead try this:
      Code:
      egen newvar=anymatch(var1-var100), v(3)
      see
      Code:
      help egen
      for more
      Thanks Rich. This is really helpful!

      Comment

      Working...
      X