Announcement

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

  • Total of Top 3 Ranked by Group

    Good evening,

    I need to find the total of reverse_ipsclean for position_rank 1-3 by group
    Here the total for reverse_ipsclean if position_rank is 1-3 is 3+5+4 = 12 (goes in the wanted column)

    Thanks


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str3 group float(position_rank reverse_ipsclean wanted)
    "dog"  1 3 12
    "dog"  2 5 12
    "dog"  3 4 12
    "dog"  4 4 12
    "dog"  5 4 12
    "dog"  6 1 12
    "dog"  7 2 12
    "dog"  8 3 12
    "dog"  9 2 12
    "dog" 10 4 12
    "dog" 11 2 12
    end

  • #2
    Disregard, I sorted it out with this...

    by group, sort: egen wanted = total(cond(position_rank < 4, reverse_ipsclean, .))

    Comment

    Working...
    X