Announcement

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

  • keep according serial number

    dear all I have a data set which has a variable name "Serial number" like (1 to 1000).



    SL i want to keep from SL
    1 5
    2 9
    3 12
    4 8
    5 9
    6 3
    7
    8
    9
    10
    11
    12
    13


    i want to keep this SL number and droop the others
    Thanks

  • #2
    Typing keep SL will keep the variable SL and drop all other variables.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      If Martin's answer is not what you want - if you desire to keep certain observations and remove the others from your data - we will need to understand your data better. What does the observation "1 5" mean, for example, since you suggest the serial number runs from 1 to 1000.

      As you have been advised before by others on Statalist, please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post, looking especially at sections 9-12 on how to best pose your question. In section 12.2 you will see

      We can understand your dataset only to the extent that you explain it clearly.
      It would be particularly helpful to post a small hand-made example, perhaps with just a few variables and observations, showing the data before the process and indicating which ones you expect to keep..

      Comment


      • #4
        i have found the solution
        the command will be like this
        keep if (Sl==594 | Sl==158 | Sl==273| Sl==63| Sl==88| Sl==575| Sl==275| Sl==521| Sl==252| Sl==159| Sl==165| Sl==268| Sl==177| | Sl==190| Sl==416| Sl==64| Sl==573 | Sl==139 | Sl==281 | Sl==462 | Sl==26 | Sl==61 | Sl==8 | Sl==594 | Sl==25)
        thanks to all


        Comment


        • #5
          See help inlist for a much less error prone approach:

          Code:
          keep if inlist(SI, 594, 158, 273, 63, 88, 575, 275, 521, 252, 159, 165, 268, 177, 190, 416, 64, 573, 139, 281, 462, 26, 61, 8, 594, 25)
          Stata/MP 14.1 (64-bit x86-64)
          Revision 19 May 2016
          Win 8.1

          Comment


          • #6
            Thanks

            Comment

            Working...
            X