Announcement

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

  • How to count persistent value for each group in panel data

    Hi all,

    I have an issue with data counting, so hopefully someone can help me. I have converted the data in long, looks like this

    ID Wave Percentage
    1 1 10%
    1 2 20%
    1 3 20%
    1 4 20%
    2 1 .
    2 2 20%
    2 3 30%
    3 4 40%
    3 1 .
    3 2 .
    3 3 30%
    3 4 40%

    I would like to count how many participants across waves had persistent percentage above e.g. 20%?

    Thank you!

    Best wishes,
    Martina

  • #2
    Martina, if a participant has a missing percentage in some wave but all the non-missing percentages are above 20%, does the participant have a persistent percentage? If yes, please refer to the first code; if no, then the second code.

    Code:
    reshape wide Percentage, i(ID) j(Wave)
    egen perc_min = rowmin(Percentage*)
    gen persist = perc_min > 0.2 & perc_min < .
    count if persist
    Code:
    reshape wide Percentage, i(ID) j(Wave)
    egen perc_min = rowmin(Percentage*)
    egen perc_miss = rowmiss(Percentage*)
    gen persist = perc_min > 0.2 & !perc_miss
    count if persist
    Last edited by Fei Wang; 29 Oct 2021, 10:56.

    Comment


    • #3
      Thank you Fei for your kind help!

      Comment

      Working...
      X