Announcement

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

  • Summing occurrences, restarting at every "."

    Hello, I am working with a data set where I have to find the difference between what I call "head_speakers" - only one occurrence - and "sub_speakers" - varying number of occurrences - and return it in the occurrence either directly under or replacing the occurrence "Total" in the variable "stop_count". I have tried many ways to do so but cannot manage to figure it out. Some sample code is provided below.


    head_speakers | sub_speakers | stop_count
    .................................................. ...........
    4957542........................................... ................
    ...........................34535.................. ................
    ...........................35232.................. ................
    ...........................453.................... ..............
    .................................................. ....Total.......
    .................................................. ...........
    .................................................. ...........
    .................................................. ..........
    32533345.......................................... ..................
    ........................4543...................... ...............
    .................................................. ...Total........
    .................................................. ....................
    .................................................. ...........
    35823583.......................................... ...................
    .........................342343................... .................
    ..........................23432................... ................
    ..........................5323.................... ...............
    ..........................54532................... ................
    .................................................. ..Total.........
    .................................................. ...........
    .................................................. ...........

    ** Despite the format of provided code, only one period is in each occurance that doesnt have a number or "Total"
    Last edited by Hailey Gretz; 07 Feb 2024, 19:26.

  • #2
    I'm sorry, but I can't make heads nor tails of your request or the sample "code". Please use -dataex- within Stata to show us a Stata-formatted dataset which we can use as a starting point. (Details of -dataex- are provided in the FAQ and can be found by typing -help dataex- into your copy of Stata.) It would also be helpful to show us what the end result of your example code should look like since this seems to be a non-standard sort of request.

    Comment

    Working...
    X