Announcement

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

  • How to calculate the time duration of each speakers and each presenters? Thanks!

    In order to get the results, I will firstly clarify the research setting to help you understand: here is a pitch data, firstly presenting session, and then QA session.
    Each presenting team has different numbers of presenters (presenterNum), for example, observation 1 has 1 presenter; observation 2 has 3 presenters, observation 5 has 3 presenters. prsterOrder indicates the order of presenters who speak up, for example, observation1 indicates only presenter 1 speak up; observation 5 indicates presenter 1 firstly speak up and then presenter 3 continued to speak up, and presenter 2 didn’t speak up.

    I want to calculate the time duration of first/second… speakers, and also want to calculate the time duration of presenter 1, 2, 3… respectively.

    *Time variables is the clock time. prster1Time indicates the beginning time of presenter 1, queston1Time indicates the beginning time of QA session.

    For observation 1, the time duration of first speaker is (14:21-08:21). For presenter 1, the time duration is (14:21-08:21)
    For observation 2, the time duration of first speaker is (43:40-36:41). For presenter 1, the time duration is (43:40-36:41), while for presenter 2 and 3, the time durations are 0 since they just showed up but without speaking.
    For observation 5, the time duration for presenter 1 is (56:56-53:00+03:32-0:00), the time duration for presenter 2 is 0, and the time duration for presenter 3 is (03:55-03:32)
    For observation 11, the time duration for presenter 1 is (22:30-17:07), the time duration for presenter 2 is (23:19-22:30); the time duration of presenter 3 is 0. The time duration of first speaker is (22:30-17:07), the time duration of second speaker is (23:19-22:30).

    This syntax is not right, just as a beginning for you: gen prster1Duration = (clock(question1Time,"ms") - clock(prster1Time,"ms"))/1000/60


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte presenterNum str6(prster1Time prster1EndTime prster2Time prster2EndTime prster3Time) str1 prster3EndTime str6 question1Time str2 prsterOrder
    1 " 08:21" ""       ""       "" ""       "" " 14:21" "1"
    3 " 36:41" ""       ""       "" ""       "" "  43:4" "1"
    2 " 22:31" ""       ""       "" ""       "" " 28:59" "1"
    2 " 17:16" ""       ""       "" ""       "" " 24:34" "1"
    3 " 53:00" "56:56
    " ""       "" " 03:32" "" " 03:55" "13"
    1 " 00:00" ""       ""       "" ""       "" " 05:15" "1"
    2 " 00:03" ""       ""       "" ""       "" " 06:50" "1"
    2 " 18:35" ""       ""       "" ""       "" " 29:11" "1"
    3 " 33:31" ""       ""       "" ""       "" " 42:02" "1"
    2 " 36:37" ""       ""       "" ""       "" " 43:38" "1"
    3 " 22:30" ""       " 17:07" "" ""       "" " 23:19" "21"
    2 " 15:25" ""       ""       "" ""       "" " 26:58" "1"
    2 " 58:05" "58:51
    " ""       "" ""       "" " 04:24" "1"
    2 " 53:46" "54:42
    " ""       "" ""       "" " 07:39" "1"
    3 " 33:06" "41:09
    " ""       "" ""       "" " 03:27" "1"
    3 " 19:12" ""       ""       "" ""       "" " 27:48" "1"
    2 " 23:34" "31:24
    " ""       "" ""       "" " 00:32" "1"
    2 " 11:45" ""       ""       "" ""       "" " 19:36" "1"
    2 " 01:57" ""       ""       "" ""       "" " 10:21" "1"
    2 " 08:25" ""       ""       "" ""       "" " 16:48" "1"
    2 " 02:40" ""       ""       "" ""       "" " 10:34" "1"
    2 " 26:04" ""       ""       "" ""       "" " 34:21" "1"
    2 " 22:42" ""       ""       "" ""       "" " 33:57" "1"
    2 " 15:37" ""       ""       "" ""       "" " 24:03" "1"
    2 " 07:34" ""       ""       "" ""       "" " 15:35" "1"
    2 " 04:51" ""       ""       "" ""       "" " 11:48" "1"
    2 " 18:16" ""       ""       "" ""       "" " 26:41" "1"
    1 " 30:49" ""       ""       "" ""       "" " 39:07" "1"
    2 " 02:09" ""       ""       "" ""       "" " 09:35" "1"
    2 " 00:06" ""       ""       "" ""       "" " 08:14" "1"
    2 " 14:23" ""       ""       "" ""       "" " 22:36" "1"
    2 " 25:28" ""       ""       "" ""       "" " 35:49" "1"
    2 " 30:47" "32:42
    " " 01:30" "" ""       "" " 06:00" "12"
    end
    Last edited by Fred Lee; 28 Oct 2022, 11:32.

  • #2
    I'm completely confused. Look at observation 5. You say that presenter 1 spoke first. But presenter 2 begins at 03:32, which is before we hear from presenter 1, who apparently asks a question at 03:55, but then goes on to give his/her own pitch at 53:00. The data you show are simply not consistent with the ordering you say is there. Moreover, I don't understand why the speaking time for presenter 1 would be 56:56-53:00 + 03:55-0:00. Where does that 0:00 come from? There is nothing that actually happens at 0:00 in the data set.

    Also, while it wasn't hard to fix, for some reason, your -dataex- example is garbled, with lines broken in the model. In the future, please post -dataex- output exactly as it comes out from Stata, and also, after posting, verify that it looks right. If somehow it got mangled, please edit your post by deleting what was there and doing it over.

    In case there is somebody out there who understands what O.P. has said in #1 and wants to try solving this using a clean -dataex-:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte presenterNum str6(prster1Time prster1EndTime prster2Time prster2EndTime prster3Time) str1 prster3EndTime str6 question1Time str2 prsterOrder
    1 " 08:21" ""       ""       "" ""       "" " 14:21" "1"
    3 " 36:41" ""       ""       "" ""       "" "  43:4" "1"
    2 " 22:31" ""       ""       "" ""       "" " 28:59" "1"
    2 " 17:16" ""       ""       "" ""       "" " 24:34" "1"
    3 " 53:00" "56:56" ""       "" " 03:32" "" " 03:55" "13"
    1 " 00:00" ""       ""       "" ""       "" " 05:15" "1"
    2 " 00:03" ""       ""       "" ""       "" " 06:50" "1"
    2 " 18:35" ""       ""       "" ""       "" " 29:11" "1"
    3 " 33:31" ""       ""       "" ""       "" " 42:02" "1"
    2 " 36:37" ""       ""       "" ""       "" " 43:38" "1"
    3 " 22:30" ""       " 17:07" "" ""       "" " 23:19" "21"
    2 " 15:25" ""       ""       "" ""       "" " 26:58" "1"
    2 " 58:05" "58:51" ""       "" ""       "" " 04:24" "1"
    2 " 53:46" "54:42" ""       "" ""       "" " 07:39" "1"
    3 " 33:06" "41:09" ""       "" ""       "" " 03:27" "1"
    3 " 19:12" ""       ""       "" ""       "" " 27:48" "1"
    2 " 23:34" "31:24" ""       "" ""       "" " 00:32" "1"
    2 " 11:45" ""       ""       "" ""       "" " 19:36" "1"
    2 " 01:57" ""       ""       "" ""       "" " 10:21" "1"
    2 " 08:25" ""       ""       "" ""       "" " 16:48" "1"
    2 " 02:40" ""       ""       "" ""       "" " 10:34" "1"
    2 " 26:04" ""       ""       "" ""       "" " 34:21" "1"
    2 " 22:42" ""       ""       "" ""       "" " 33:57" "1"
    2 " 15:37" ""       ""       "" ""       "" " 24:03" "1"
    2 " 07:34" ""       ""       "" ""       "" " 15:35" "1"
    2 " 04:51" ""       ""       "" ""       "" " 11:48" "1"
    2 " 18:16" ""       ""       "" ""       "" " 26:41" "1"
    1 " 30:49" ""       ""       "" ""       "" " 39:07" "1"
    2 " 02:09" ""       ""       "" ""       "" " 09:35" "1"
    2 " 00:06" ""       ""       "" ""       "" " 08:14" "1"
    2 " 14:23" ""       ""       "" ""       "" " 22:36" "1"
    2 " 25:28" ""       ""       "" ""       "" " 35:49" "1"
    2 " 30:47" "32:42" " 01:30" "" ""       "" " 06:00" "12"
    end

    Comment


    • #3
      Thanks Clyde, prster1EndTime indicates the first part video ended at "56:56", and the next part of video automatially begins at "0:00", this explains where "0:00" comes from.
      If the prster1EndTime is blank, it indicates the presentation is recorded in a full video rather than two parts.
      For observation 5, the first part of video shows that presenter 1 begins at 53:00, then first part of video ends at 56:56, and second part video shows the presenter 1 continues until 03:32, then presenter 3 speak until the first question time (03:55).
      Last edited by Fred Lee; 28 Oct 2022, 12:33.

      Comment


      • #4
        I'm sorry. Perhaps I'm dense, but I can't make sense of that explanation. I don't understand how we can tell from the data that there is a second video and the clock restarts at 0:00. The remark that when a presenter's end time is missing, it indicates that the presentation is recorded in a full video, I suppose, is supposed to answer that, but I don't see how. In fact, end time is only given in a handful of observations. There are many other observations in the data set where things appear to be in the wrong order. I suppose there is some underlying way to explain it all, but I'm not grasping it. Hopefully, somebody else is and will be able to help you.

        Comment


        • #5
          Hi Clyde, thanks for your commens to help me clarify the siatuation. The prster1EndTime should be length of first part video (if there are two parts of video), if this variable is missing, it indicates the presentations were recorded in a video.

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input byte presenterNum2 str6(prster1Time firstPartEndTime prster2Time prster3Time question1Time) str2 prsterOrder
          1 " 08:21" ""       ""       ""       " 14:21" "1" 
          3 " 36:41" ""       ""       ""       "  43:4" "1" 
          2 " 22:31" ""       ""       ""       " 28:59" "1" 
          2 " 17:16" ""       ""       ""       " 24:34" "1" 
          3 " 53:00" "56:56" ""       " 03:32" " 03:55" "13"
          1 " 00:00" ""       ""       ""       " 05:15" "1" 
          2 " 00:03" ""       ""       ""       " 06:50" "1" 
          2 " 18:35" ""       ""       ""       " 29:11" "1" 
          3 " 33:31" ""       ""       ""       " 42:02" "1" 
          2 " 36:37" ""       ""       ""       " 43:38" "1" 
          3 " 22:30" ""       " 17:07" ""       " 23:19" "21"
          2 " 15:25" ""       ""       ""       " 26:58" "1" 
          2 " 58:05" "58:51" ""       ""       " 04:24" "1" 
          2 " 53:46" "54:42" ""       ""       " 07:39" "1" 
          3 " 33:06" "41:09" ""       ""       " 03:27" "1" 
          3 " 19:12" ""       ""       ""       " 27:48" "1" 
          2 " 23:34" "31:24" ""       ""       " 00:32" "1" 
          2 " 11:45" ""       ""       ""       " 19:36" "1" 
          2 " 01:57" ""       ""       ""       " 10:21" "1" 
          2 " 08:25" ""       ""       ""       " 16:48" "1" 
          2 " 02:40" ""       ""       ""       " 10:34" "1" 
          2 " 26:04" ""       ""       ""       " 34:21" "1" 
          2 " 22:42" ""       ""       ""       " 33:57" "1" 
          2 " 15:37" ""       ""       ""       " 24:03" "1" 
          2 " 07:34" ""       ""       ""       " 15:35" "1" 
          2 " 04:51" ""       ""       ""       " 11:48" "1" 
          2 " 18:16" ""       ""       ""       " 26:41" "1" 
          1 " 30:49" ""       ""       ""       " 39:07" "1" 
          2 " 02:09" ""       ""       ""       " 09:35" "1" 
          2 " 00:06" ""       ""       ""       " 08:14" "1" 
          2 " 14:23" ""       ""       ""       " 22:36" "1" 
          2 " 25:28" ""       ""       ""       " 35:49" "1" 
          2 " 30:47" "32:42" " 01:30" ""       " 06:00" "12"
          end

          Comment


          • #6
            Here's one attempt at doing this:

            Code:
            foreach var of varlist *Time {
                replace `var' = trim(`var')
                gen int `var'_num = real(substr(`var',1,2))*60 + real(substr(`var'),4,2)
            }
            
            forval i=1/3 {
                gen byte pr`i'_code = real(substr(trim(prsterOrder),`i',1))
            }
            
            forval i=1/3 {
                gen int pr`i'_start = .
                forval j = 1/3 {
                    replace pr`i'_start = prster`j'Time_num if pr`i'_code == `j'
                }
            }
            
            forval i=1/3 {
                gen int pr`i'_end = ., after(pr`i'_start)
                if `i'<3 {
                    replace pr`i'_end = pr`=`i'+1'_start if !missing(pr`=`i'+1'_start) & !missing(pr`i'_code)
                }
                replace pr`i'_end = question1Time_num if missing(pr`i'_end) & !missing(pr`i'_code)
                
                gen int pr`i'_duration = cond(pr`i'_end - pr`i'_start >=0 , pr`i'_end - pr`i'_start, pr`i'_end + (firstPartEndTime_num - pr`i'_start))
                replace pr`i'_duration = 0 if missing(pr`i'_duration) & `i'<= presenterNum2
            }
            
            
            forval i = 1/3 {
                if `i' < 3 replace pr2_code = `i' if presenterNum2 > 1 & pr1_code != `i' & missing(pr2_code)
                if `i' == 3 replace pr2_code = 3 if presenterNum2 == 3 & missing(pr2_code)
                replace pr3_code = `i' if presenterNum2 == 3 & !inlist(`i',pr1_code,pr2_code) & missing(pr3_code)
            }
            
            drop pr?_start pr?_end *Time_num
            This produces:

            Code:
            . li , noobs
            
              +----------------------------------------------------------------------------------------------------------------------------------------------+
              | presen~2   pr~1Time   firstP~e   pr~2Time   pr~3Time   questi~e   prster~r   pr1_code   pr2_code   pr3_code   pr1_du~n   pr2_du~n   pr3_du~n |
              |----------------------------------------------------------------------------------------------------------------------------------------------|
              |        1      08:21                                       14:21          1          1          .          .        360          .          . |
              |        3      36:41                                       43:40          1          1          2          3        419          0          0 |
              |        2      22:31                                       28:59          1          1          2          .        388          0          . |
              |        2      17:16                                       24:34          1          1          2          .        438          0          . |
              |        3      53:00      56:56                 03:32      03:55         13          1          3          2        448         23          0 |
              |----------------------------------------------------------------------------------------------------------------------------------------------|
              |        1      00:00                                       05:15          1          1          .          .        315          .          . |
              |        2      00:03                                       06:50          1          1          2          .        407          0          . |
              |        2      18:35                                       29:11          1          1          2          .        636          0          . |
              |        3      33:31                                       42:02          1          1          2          3        511          0          0 |
              |        2      36:37                                       43:38          1          1          2          .        421          0          . |
              |----------------------------------------------------------------------------------------------------------------------------------------------|
              |        3      22:30                 17:07                 23:19         21          2          1          3        323         49          0 |
              |        2      15:25                                       26:58          1          1          2          .        693          0          . |
              |        2      58:05      58:51                            04:24          1          1          2          .        310          0          . |
              |        2      53:46      54:42                            07:39          1          1          2          .        515          0          . |
              |        3      33:06      41:09                            03:27          1          1          2          3        690          0          0 |
              |----------------------------------------------------------------------------------------------------------------------------------------------|
              |        3      19:12                                       27:48          1          1          2          3        516          0          0 |
              |        2      23:34      31:24                            00:32          1          1          2          .        502          0          . |
              |        2      11:45                                       19:36          1          1          2          .        471          0          . |
              |        2      01:57                                       10:21          1          1          2          .        504          0          . |
              |        2      08:25                                       16:48          1          1          2          .        503          0          . |
              |----------------------------------------------------------------------------------------------------------------------------------------------|
              |        2      02:40                                       10:34          1          1          2          .        474          0          . |
              |        2      26:04                                       34:21          1          1          2          .        497          0          . |
              |        2      22:42                                       33:57          1          1          2          .        675          0          . |
              |        2      15:37                                       24:03          1          1          2          .        506          0          . |
              |        2      07:34                                       15:35          1          1          2          .        481          0          . |
              |----------------------------------------------------------------------------------------------------------------------------------------------|
              |        2      04:51                                       11:48          1          1          2          .        417          0          . |
              |        2      18:16                                       26:41          1          1          2          .        505          0          . |
              |        1      30:49                                       39:07          1          1          .          .        498          .          . |
              |        2      02:09                                       09:35          1          1          2          .        446          0          . |
              |        2      00:06                                       08:14          1          1          2          .        488          0          . |
              |----------------------------------------------------------------------------------------------------------------------------------------------|
              |        2      14:23                                       22:36          1          1          2          .        493          0          . |
              |        2      25:28                                       35:49          1          1          2          .        621          0          . |
              |        2      30:47      32:42      01:30                 06:00         12          1          2          .        205        270          . |
              +----------------------------------------------------------------------------------------------------------------------------------------------+
            A few things:
            • Durations are in seconds.
            • the duration variables are for the first, second and third presenter. The pr?_code variables tell you who the presenters were.
            • Towards the end of the code, I assume that if the end time is less than the start time for a presenter, then we need to use the firstPartEndTime to compute the correct duration. This may or may not be an accurate assumption (are there cases where someone e.g started at 1:00 and ended at 3:00, but that involved a change of video, i.e. it was not two minutes but 59+3 = 62 minutes?)
            • I manually corrected one time, in obs 2, from "43:4" to "43:40", assuming this was some sort of typo. If not, we can add a bit of code to fix such errors in time entry.
            Last edited by Hemanshu Kumar; 29 Oct 2022, 06:17.

            Comment


            • #7
              Thanks so much, Hemanshu!
              The assumption in my case is correct!
              "43:4" is a mistake, you are right!

              Thanks a ton for understanding me and helping me out! I will learn and absorb this for a moment!
              Thanks again!!!

              Comment


              • #8
                HI Hemanshu Kumar, if the maximum presenters is 4, how to change the syntax below corresponding? Thanks!
                Code:
                forval i = 1/3 {
                    if `i' < 3 replace pr2_code = `i' if presenterNum2 > 1 & pr1_code != `i' & missing(pr2_code)
                    if `i' == 3 replace pr2_code = 3 if presenterNum2 == 3 & missing(pr2_code)
                    replace pr3_code = `i' if presenterNum2 == 3 & !inlist(`i',pr1_code,pr2_code) & missing(pr3_code)
                }

                Comment


                • #9
                  Can you attach a data extract with cases that have up to 4 presenters?

                  Comment


                  • #10
                    By the way, I want to calculate the duration for male presenters and female presenters respectively.
                    prst1Female prst2Female prst3Female prst4Female indicates the gender of presenter 1, 2, 3, 4, in accordance with the prsterOrder.
                    I thought we need to calculate the gender of first, second, third and fourth presenters and then sum it.

                    Code:
                    * Example generated by -dataex-. For more info, type help dataex
                    clear
                    input float presenterNum2 str6(prster1Time prster2Time prster3Time question1Time firstPartEndTime) str96 prsterOrder byte(prst1Female prst2Female prst3Female prst4Female)
                    1 " 08:21" ""       ""       " 14:21" ""       "1"  0 . . .
                    4 " 36:41" ""       ""       " 43:44" ""       "1"  0 0 1 1
                    2 " 22:31" ""       ""       " 28:59" ""       "1"  0 1 . .
                    2 " 17:16" ""       ""       " 24:34" ""       "1"  0 1 . .
                    3 " 53:00" ""       " 03:32" " 03:59" "56:56" "13" 0 0 0 .
                    1 " 00:00" ""       ""       " 05:15" ""       "1"  0 . . .
                    2 " 00:03" ""       ""       " 06:50" ""       "1"  0 1 . .
                    2 " 18:35" ""       ""       " 29:11" ""       "1"  0 0 . .
                    3 " 33:31" ""       ""       " 42:02" ""       "1"  0 0 0 .
                    2 " 36:37" ""       ""       " 43:38" ""       "1"  0 0 . .
                    2 " 17:07" " 22:30" ""       " 23:19" ""       "12" 0 0 . .
                    2 " 15:25" ""       ""       " 26:58" ""       "1"  0 0 . .
                    2 " 58:05" ""       ""       " 04:24" "58:51" "1"  0 1 . .
                    2 " 53:46" ""       ""       " 07:39" "54:42" "1"  0 0 . .
                    3 " 33:06" ""       ""       " 03:27" "41:09" "1"  1 0 1 .
                    3 " 19:12" ""       ""       " 27:48" ""       "1"  0 0 1 .
                    2 " 23:34" ""       ""       " 00:32" "31:24" "1"  0 1 . .
                    2 " 11:45" ""       ""       " 19:36" ""       "1"  0 1 . .
                    2 " 01:57" ""       ""       " 10:21" ""       "1"  0 0 . .
                    2 " 08:25" ""       ""       " 16:48" ""       "1"  0 1 . .
                    2 " 02:40" ""       ""       " 10:34" ""       "1"  0 1 . .
                    2 " 26:04" ""       ""       " 34:21" ""       "1"  0 0 . .
                    2 " 22:42" ""       ""       " 33:57" ""       "1"  0 0 . .
                    2 " 15:37" ""       ""       " 24:03" ""       "1"  0 1 . .
                    2 " 07:34" ""       ""       " 15:35" ""       "1"  0 1 . .
                    2 " 04:51" ""       ""       " 11:48" ""       "1"  0 0 . .
                    2 " 18:16" ""       ""       " 26:41" ""       "1"  0 0 . .
                    1 " 30:49" ""       ""       " 39:07" ""       "1"  0 . . .
                    2 " 02:09" ""       ""       " 09:35" ""       "1"  0 0 . .
                    2 " 00:06" ""       ""       " 08:14" ""       "1"  0 1 . .
                    2 " 14:23" ""       ""       " 22:36" ""       "1"  0 1 . .
                    2 " 25:28" ""       ""       " 35:49" ""       "1"  0 0 . .
                    2 " 30:47" " 01:30" ""       " 06:00" "32:42" "12" 0 0 . .
                    end

                    Comment


                    • #11
                      Also, that bit of code essentially fills out pr?_codes for the presenters who did not speak up. When more than one presenter did not speak up, the non-speakers' pr?_codes are arbitrary. Are these even useful for you?

                      Comment


                      • #12
                        Your data extract in #10 lacks any variable for prster4Time. Could you include that and at least some rows where 4 presenters spoke, so that this variable is non-missing?

                        Comment


                        • #13
                          Thanks a ton!
                          Originally posted by Hemanshu Kumar View Post
                          Also, that bit of code essentially fills out pr?_codes for the presenters who did not speak up. When more than one presenter did not speak up, the non-speakers' pr?_codes are arbitrary. Are these even useful for you?
                          "When more than one presenter did not speak up, the non-speakers' pr?_codes are arbitrary." That's OK if it doesn't affect the calculation of duration for male presenters and female presenters respectively.

                          Code:
                          * Example generated by -dataex-. For more info, type help dataex
                          clear
                          input byte presenterNum2 str5(prster1Time prster2Time prster3Time) str1 prster4Time str5 question1Time str6 firstPartEndTime str2 prsterOrder byte(prst1Female prst2Female prst3Female prst4Female)
                          1 "08:21" ""      ""      "" "14:21" ""       "1"  0 . . .
                          4 "36:41" ""      ""      "" "43:44" ""       "1"  0 0 1 1
                          2 "22:31" ""      ""      "" "28:59" ""       "1"  0 1 . .
                          2 "17:16" ""      ""      "" "24:34" ""       "1"  0 1 . .
                          4 "53:00" "54:45"      "03:32" "03:45" "03:59" "56:56" "1324" 0 0 0 1
                          1 "00:00" ""      ""      "" "05:15" ""       "1"  0 . . .
                          2 "00:03" ""      ""      "" "06:50" ""       "1"  0 1 . .
                          2 "18:35" ""      ""      "" "29:11" ""       "1"  0 0 . .
                          3 "33:31" ""      ""      "" "42:02" ""       "1"  0 0 0 .
                          2 "36:37" ""      ""      "" "43:38" ""       "1"  0 0 . .
                          2 "17:07" "22:30" ""      "" "23:19" ""       "12" 0 0 . .
                          2 "15:25" ""      ""      "" "26:58" ""       "1"  0 0 . .
                          2 "58:05" ""      ""      "" "04:24" "58:51" "1"  0 1 . .
                          2 "53:46" ""      ""      "" "07:39" "54:42" "1"  0 0 . .
                          3 "33:06" ""      ""      "" "03:27" "41:09" "1"  1 0 1 .
                          3 "19:12" ""      ""      "" "27:48" ""       "1"  0 0 1 .
                          2 "23:34" ""      ""      "" "00:32" "31:24" "1"  0 1 . .
                          2 "11:45" ""      ""      "" "19:36" ""       "1"  0 1 . .
                          2 "01:57" ""      ""      "" "10:21" ""       "1"  0 0 . .
                          2 "08:25" ""      ""      "" "16:48" ""       "1"  0 1 . .
                          2 "02:40" ""      ""      "" "10:34" ""       "1"  0 1 . .
                          2 "26:04" ""      ""      "" "34:21" ""       "1"  0 0 . .
                          2 "22:42" ""      ""      "" "33:57" ""       "1"  0 0 . .
                          2 "15:37" ""      ""      "" "24:03" ""       "1"  0 1 . .
                          2 "07:34" ""      ""      "" "15:35" ""       "1"  0 1 . .
                          2 "04:51" ""      ""      "" "11:48" ""       "1"  0 0 . .
                          2 "18:16" ""      ""      "" "26:41" ""       "1"  0 0 . .
                          1 "30:49" ""      ""      "" "39:07" ""       "1"  0 . . .
                          2 "02:09" ""      ""      "" "09:35" ""       "1"  0 0 . .
                          2 "00:06" ""      ""      "" "08:14" ""       "1"  0 1 . .
                          2 "14:23" ""      ""      "" "22:36" ""       "1"  0 1 . .
                          2 "25:28" ""      ""      "" "35:49" ""       "1"  0 0 . .
                          2 "30:47" "01:30" ""      "" "06:00" "32:42" "12" 0 0 . .
                          end

                          Comment


                          • #14
                            So let's skip that code for filling out pr?_codes for non-speakers. Here is the rest of it, modified for 4 speakers, as well as the code for computing duration by gender:

                            Code:
                            foreach var of varlist *Time {
                                replace `var' = trim(`var')
                                gen int `var'_num = real(substr(`var',1,2))*60 + real(substr(`var'),4,2)
                            }
                            
                            forval i=1/4 {
                                gen byte pr`i'_code = real(substr(trim(prsterOrder),`i',1))
                            }
                            
                            forval i=1/4 {
                                gen byte pr`i'_female = .
                                gen int pr`i'_start = .
                                forval j = 1/4 {
                                    replace pr`i'_female = prst`j'Female if pr`i'_code == `j'
                                    replace pr`i'_start = prster`j'Time_num if pr`i'_code == `j'
                                }
                            }
                            
                            
                            forval i=1/4 {
                                gen int pr`i'_end = ., after(pr`i'_start)
                                if `i'<4 {
                                    replace pr`i'_end = pr`=`i'+1'_start if !missing(pr`=`i'+1'_start) & !missing(pr`i'_code)
                                }
                                replace pr`i'_end = question1Time_num if missing(pr`i'_end) & !missing(pr`i'_code)
                                
                                gen int pr`i'_duration = cond(pr`i'_end - pr`i'_start >=0 , pr`i'_end - pr`i'_start, pr`i'_end + (firstPartEndTime_num - pr`i'_start))
                                replace pr`i'_duration = 0 if missing(pr`i'_duration) & `i'<= presenterNum2
                            }
                            
                            * add up durations by gender
                            
                            egen int duration_total = rowtotal(pr?_duration)
                            gen int duration_female = 0
                            forval i = 1/4 {
                                replace duration_female = duration_female + pr`i'_duration if !missing(pr`i'_code) & pr`i'_female == 1
                            }
                            gen int duration_male = duration_total - duration_female
                            egen byte any_female = anymatch(prst?Female), value(1)
                            egen byte any_male = anymatch(prst?Female), value(0)
                            replace duration_female = . if !any_female
                            replace duration_male = . if !any_male
                            
                            drop pr?_start pr?_end *Time_num any_*

                            Comment


                            • #15
                              Thanks so much for the quick reply! I found the calculations of duraiton for observation 5,13 15 are not right.
                              Code:
                              * Example generated by -dataex-. For more info, type help dataex
                              clear
                              input float presenterNum2 str6(prster1Time prster2Time prster3Time) str1 prster4Time str6(question1Time firstPartEndTime) str96 prsterOrder byte(prst1Female prst2Female prst3Female prst4Female)
                              1 " 08:21" ""       ""       "" " 14:21" ""       "1"  0 . . .
                              3 " 36:41" ""       ""       "" " 43:44" ""       "1"  0 0 1 .
                              2 " 22:31" ""       ""       "" " 28:59" ""       "1"  0 1 . .
                              2 " 17:16" ""       ""       "" " 24:34" ""       "1"  0 1 . .
                              3 " 53:00" ""       " 03:32" "" " 03:59" "56:56
                              " "13" 0 0 0 .
                              1 " 00:00" ""       ""       "" " 05:15" ""       "1"  0 . . .
                              2 " 00:03" ""       ""       "" " 06:50" ""       "1"  0 1 . .
                              2 " 18:35" ""       ""       "" " 29:11" ""       "1"  0 0 . .
                              3 " 33:31" ""       ""       "" " 42:02" ""       "1"  0 0 0 .
                              2 " 36:37" ""       ""       "" " 43:38" ""       "1"  0 0 . .
                              2 " 17:07" " 22:30" ""       "" " 23:19" ""       "12" 0 0 . .
                              2 " 15:25" ""       ""       "" " 26:58" ""       "1"  0 0 . .
                              2 " 58:05" ""       ""       "" " 04:24" "58:51
                              " "1"  0 1 . .
                              2 " 53:46" ""       ""       "" " 07:39" "54:42
                              " "1"  0 0 . .
                              3 " 33:06" ""       ""       "" " 03:27" "41:09
                              " "1"  1 0 1 .
                              3 " 19:12" ""       ""       "" " 27:48" ""       "1"  0 0 1 .
                              2 " 23:34" ""       ""       "" " 00:32" "31:24
                              " "1"  0 1 . .
                              2 " 11:45" ""       ""       "" " 19:36" ""       "1"  0 1 . .
                              2 " 01:57" ""       ""       "" " 10:21" ""       "1"  0 0 . .
                              2 " 08:25" ""       ""       "" " 16:48" ""       "1"  0 1 . .
                              2 " 02:40" ""       ""       "" " 10:34" ""       "1"  0 1 . .
                              2 " 26:04" ""       ""       "" " 34:21" ""       "1"  0 0 . .
                              2 " 22:42" ""       ""       "" " 33:57" ""       "1"  0 0 . .
                              2 " 15:37" ""       ""       "" " 24:03" ""       "1"  0 1 . .
                              2 " 07:34" ""       ""       "" " 15:35" ""       "1"  0 1 . .
                              2 " 04:51" ""       ""       "" " 11:48" ""       "1"  0 0 . .
                              2 " 18:16" ""       ""       "" " 26:41" ""       "1"  0 0 . .
                              1 " 30:49" ""       ""       "" " 39:07" ""       "1"  0 . . .
                              2 " 02:09" ""       ""       "" " 09:35" ""       "1"  0 0 . .
                              2 " 00:06" ""       ""       "" " 08:14" ""       "1"  0 1 . .
                              2 " 14:23" ""       ""       "" " 22:36" ""       "1"  0 1 . .
                              2 " 25:28" ""       ""       "" " 35:49" ""       "1"  0 0 . .
                              2 " 30:47" " 01:30" ""       "" " 06:00" "32:42
                              " "12" 0 0 . .
                              end

                              Comment

                              Working...
                              X