Announcement

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

  • List command for listing non-contiguous observations

    Hi all
    Is there a way to use list command with non-contiguous observations

    for example if I wanted to list observation numbers 1/4 and then 8/15 and 20/22 in one line of code using the list command

    regards
    RS

  • #2
    I don't think there's anything completely simple,but you can accomplish it with:

    Code:
    gen byte toshow = inrange(_n, 1, 4) | inrange(_n, 8, 15) | inrange(_n, 20, 22)
    list if toshow

    Comment


    • #3
      Hello Ram. Try this. Replace v1 v2 v3 with your own variables.

      Code:
      list v1 v2 v3 if inrange(_n,1,4) | inrange(_n,8,15) | inrange(_n,20,22)
      --
      Bruce Weaver
      Email: [email protected]
      Version: Stata/MP 18.5 (Windows)

      Comment


      • #4
        Beautiful, thanks Bruce and Clyde

        Comment

        Working...
        X