This is the first time I am posting on StatList.
I have a time series data, in which I have variables, comp_id hacker report_day resolve_day time_line2 resolve_day_used report_ids
Report day is the time when the report was submitted to the company and resolve day is the time when the same report was finished by the company.
Each row is at report-level, first when it is started and second when it is completed. So, for each report_id, we will have two entries in the data.
I want to calculate the running sum of a company calculating the number of hacker they have worked wirth prior to starting the new report.
I am calling the new variable, Diverse Experience (DiverseExp). It is a measure of the diversity of experiences of a company has gained, in terms of working with different hacker over time. Or we can it is, how many people a company has worked with before working with on the focal report.
Currently, the data is sorted by comp_id, time_line2, and hacker. I have given the sample table and Stata code below.
Again, the new variable (DiverseExp) will measure, at the time of receiving a new report, how many hackers a company has worked with previously. I have given the example values below.
comp_id hacker report_day resolve_day time_line2 resolve_day_used report_ids Report_closed DiverseExp 1 gianko 2/18/14 9/15/16 2/18/14 0 20861 0 0 1 talko 9/16/14 9/15/16 9/16/14 0 36264 0 0 1 guido 1/27/15 12/7/15 1/27/15 0 103991 0 0 1 guido 1/27/15 12/7/15 12/7/15 1 103991 0 0 1 gianko 2/18/14 9/15/16 9/15/16 1 20861 0 0 1 talko 9/16/14 9/15/16 9/15/16 1 36264 0 0 1 danse 12/26/16 1/10/17 12/26/16 0 194065 3 2 1 danse 12/26/16 1/10/17 1/10/17 1 194065 3 2 1 javier_sensepost 6/20/17 7/11/17 6/20/17 0 241610 4 3 1 regilero 6/29/17 7/11/17 6/29/17 0 244459 4 3 1 javier_sensepost 6/20/17 7/11/17 7/11/17 1 241610 5 4 1 regilero 6/29/17 7/11/17 7/11/17 1 244459 5 4 1 hanno 9/19/17 12/12/17 9/19/17 0 269568 6 1 hanno 9/19/17 12/12/17 12/12/17 1 269568 1 cy1337 7/20/18 10/4/18 7/20/18 0 384839 1 bobrov 9/13/18 10/1/18 9/13/18 0 409512 1 bobrov 9/13/18 10/1/18 10/1/18 1 409512 1 cy1337 7/20/18 10/4/18 10/4/18 1 384839 2 johnleitch 1/12/16 3/19/16 1/12/16 0 110352 2 johnleitch 1/12/16 3/19/16 3/19/16 1 110352 2 geeknik 2/21/17 5/24/17 2/21/17 0 207983 2 geeknik 2/21/17 5/24/17 5/24/17 1 207983
Code:* Example generated by -dataex-. To install: ssc install dataex clear input int comp_id long hacker float(report_day resolve_day time_line2 resolve_day_used) long report_ids 0 2263 19662 19662 19662 1 185 0 2263 19662 19662 19662 0 185 0 6153 19668 19690 19668 0 404 0 597 19669 19684 19669 0 3557 0 2996 19669 19670 19669 0 3245 0 2996 19669 19669 19669 1 3493 0 2996 19669 19669 19669 0 3493 0 3020 19669 19684 19669 0 3589 0 3921 19669 19670 19669 0 3697 0 5327 19669 19669 19669 1 3432 0 5327 19669 19669 19669 0 3432 0 2996 19669 19670 19670 1 3245 0 2996 19670 19670 19670 0 3976 0 2996 19670 19670 19670 1 3976 0 3921 19669 19670 19670 1 3697 0 6420 19670 19683 19670 0 4194 0 5572 19671 19684 19671 0 4248 0 1880 19674 19674 19674 1 4570 0 1880 19674 19674 19674 0 4570 0 1880 19676 19683 19676 0 4658 end format %td report_day format %td resolve_day format %td time_line2 label values hacker hacker label def hacker 597 "appsecure_in", modify label def hacker 1880 "dutchgraa", modify label def hacker 2263 "gazly", modify label def hacker 2996 "janpaul123", modify label def hacker 3020 "javidhussain21", modify label def hacker 3921 "mathias", modify label def hacker 5327 "robots-txt", modify label def hacker 5572 "satishb3", modify label def hacker 6153 "szgru", modify label def hacker 6420 "tomvg", modify label values report_ids report_ids label def report_ids 185 "110", modify label def report_ids 404 "120", modify label def report_ids 3245 "263", modify label def report_ids 3432 "275", modify label def report_ids 3493 "280", modify label def report_ids 3557 "284", modify label def report_ids 3589 "288", modify label def report_ids 3697 "298", modify label def report_ids 3976 "321", modify label def report_ids 4194 "345", modify label def report_ids 4248 "353", modify label def report_ids 4570 "390", modify label def report_ids 4658 "400", modify
Please let me know if there are more questions.
Thank you in advance.
0 Response to Running sum by a group based on another group and time.
Post a Comment