Announcement

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

  • varlist[#] - what do the brackets do?

    Hi all,

    as my title suggests, I can't figure out what square brackets behind varlist does. For example
    Code:
     
     bysort id: drop if year[1] < 10
    Does this drop all observations with a certain id if the first observation with that id fulfils the condition year<10?

    Thank you in advance,
    Marco

  • #2
    Marco:
    after having sorted for -id-, Stata will drop all the observations for which the first value of the variable -year- is lower than 10.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      What's the intent here? This might make more sense

      Code:
      bysort id (year) : drop if year[1] < 10
      as otherwise you are at the mercy of year being unsorted for each identifier (with nothing else said).

      Comment

      Working...
      X