Announcement

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

  • Data problem (drop certain data)? to perform signrank test.

    I want to conduct a signrank test for the following data:
    premax1 postmax1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    .3333333 1
    .3333333 1
    .3333333 1
    .3333333 1
    .3333333 1
    .3333333 1
    .5 .6666667
    .5 .6666667
    .5 .6666667
    .5 .6666667
    .5 .6666667
    .5 .6666667
    .8333333 .6666667
    .8333333 .6666667
    .8333333 .6666667
    .8333333 .6666667
    .8333333 .6666667
    .8333333 .6666667

    ....
    and so on.
    How could I delete the repeated variables in the data?
    Make the data becomes like this:?
    premax1 postmax1
    1 1
    .3333333 1
    .5 .6666667
    .8333333 .6666667


    Thank you very much
































































  • #2
    bys premax1 postmax1 : keep if _n == 1
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      thank you very much. I have other variables in the data. Can I generate a new variable out of it but not delete all the other observations?

      Comment


      • #4
        bys premax1 postmax1 : gen byte mark = (_n == 1)
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Maarten's code assumes that a given pair of values can occur just once. But from your example blocks of identical values occur as blocks of 6. That's a different problem for which

          Code:
          if mod(_n, 6) == 1
          is one solution. Actually any value from 0 to 5 would work.

          Comment


          • #6
            Thank you! it is not the results I want but I will work on the bysort command.

            Comment


            • #7
              I do not know if this might help you, but you can write: help duplicates_dlg and it gives you several options on what to do with duplicates.
              Hope it helps

              Comment


              • #8
                The duplicates command is one I am fond of, but I don't think it helps here. What remains unclear is why observations occur in blocks of 6; why the poster only wants to work with one in each block; and whether the two values in a block could occur in another block.

                Comment

                Working...
                X