Announcement

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

  • Help using the browse (br) command using if

    Hi StataList.

    How can I use the browse command to display certain observations from four specific waves of data (panel data)? When I enter the following, the br window is empty.
    Code:
    br xwaveid edlev empstat marstat if wave==4 & wave==7 & wave==10 & wave==14
    My error is surely in the 'if' part of the command, so any help is kindly appreciated.

    Best, Chris

  • #2
    You want | (or) not & (and).

    You’re thinking that you want several waves, but Stata works observation-wise and a wave can’t be equal to two different values.

    Comment


    • #3
      #2 was posted in a 5-minute gap in teaching.

      Code:
       
       br xwaveid edlev empstat marstat if inlist(wave, 4, 7, 10, 14)
      is another way to do it.

      Comment


      • #4
        Thank you Nick Cox that worked a charm.

        Comment


        • #5
          Chris - one problem with your original statement was that you used & so it would only evaluate to true if wave equaled all those values at once (which it obviously cannot do).

          br xwaveid edlev empstat marstat if wave==4 | wave==7 | wave==10 | wave==14 might work (I haven't checked it).

          Comment


          • #6
            #5 will work. It's equivalent to #2 and #3.

            The difficulty with #1 is that what you mean is closer to

            Code:
            (br xwaveid edlev empstat marstat if wave==4)  & (br xwaveid edlev empstat marstat if wave== 7)  ...
            That isn't legal, at all, but the fix as said is to use |

            Comment


            • #7
              Thank you Nick Cox and Phil Bromiley for your clarification/help. It is very much appreciated.

              Comment

              Working...
              X