Announcement

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

  • calculate all values without repetition

    How do I get one value when I want to calculate all values without repetition?
    Attached Files

  • #2
    That depends on what you want that value to be: the sum, the mean, do you want to drop duplicate rows?
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      yes, I want just one of the value and dropp the duplicate.

      Comment


      • #4
        Code:
        bysort id_notice_can year value2 : 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


        • #5
          thank you so much

          Comment


          • #6
            it seems doesn't work. this syntax, delete the observations. I want to keep them but in caculation use one of the values.

            Comment


            • #7
              Code:
               bysort id_notice_can year value2 : gen byte mark = _n == 1
              some_other_command_doing_some_unspecified_calculation if mark == 1
              ---------------------------------
              Maarten L. Buis
              University of Konstanz
              Department of history and sociology
              box 40
              78457 Konstanz
              Germany
              http://www.maartenbuis.nl
              ---------------------------------

              Comment


              • #8
                thank you

                Comment

                Working...
                X