Announcement

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

  • Looking for help coding

    Dear Statalist Members,
    I am new to Stata and the Forum. Please kindly help me with coding the following problem,

    I am conducting a research using data from a local football clubs. From the spreadsheet I have, at the beginning of each month in a given team:

    1st, I would like to calculate for each player (forwarder) the total number of goals they scored within 1 year preceding the 1st of every month.
    2nd, I would like to determine the maximum goal against a single goalkeeper in the same time window i.e., within 1 year preceding the 1st of every month. For example, in a team AR010, and for player BKX9M before 1st of Mar 2020, this would be 5 - the scores he had against a single goalkeeper - Jesen. Notice his score on 1st of Mar 2020 is not counted as I want to consider only within one year before every 1st month.

    3rd, I would like to compute, for each player, the share of max goal against a single player counts in a total scores as (the one computed in 2nd/total scores determined at 1st).

    Note that for a given month, if a player has less than 2 GameDates within 1 year before every month, I would leave it missing. For example, player GHBEO has just two games preceding 12th of May 2020 in a team AR01. And I will leave it missing.


    Code:
      
    team player ScoredAgainst GameDate
    AR010 BKX9M Jesen 16-Sep-19
    AR010 BKX9M Mark 12-Nov-19
    AR010 BKX9M Jesen 14-Dec-19
    AR010 BKX9M Jesen 01-Jan-20
    AR010 BKX9M Jesen 12-Jan-20
    AR010 BKX9M Jesen 02-Feb-20
    AR010 BKX9M Jesen 01-Mar-20
    AR010 BKX9M Mark 12-Mar-20
    AR010 BKX9M Parker 12-May-20
    AR010 KCH6W Jesen 16-Sep-19
    AR010 KCH6W Parker 18-Mar-20
    AR010 KCH6W Mark 30-Apr-20
    AR010 KCH6W Parker 12-May-20
    AR010 KCH6W Parker 01-Jun-20
    AR010 KCH6W Parker 15-Jun-20
    AR010 KCH6W Parker 12-Jul-20
    AR010 GHBEO Parker 28-Mar-20
    AR010 GHBEO Parker 12-Apr-20
    AR010 GHBEO Parker 12-May-20
    MAN78 NMD8B Mark 14-Sep-19
    MAN78 NMD8B Mark 17-Nov-19
    MAN78 NMD8B Mark 01-Dec-19
    MAN78 NMD8B Parker 14-Dec-19
    MAN78 NMD8B William 12-Jan-20
    MAN78 NMD8B Mark 28-Jan-20
    MAN78 NMD8B Mark 13-May-20
    MAN78 NMD8B Mark 23-Aug
    MAN78 NMD8B Mark 01-Sep-20
    MAN78 NMD8B Mark 15-Sep-20
    MAN78 MYD8B Mark 28-Jan-20
    MAN78 MYD8B Mark 13-May-20
    MAN78 MYD8B Mark 23-Aug
    MAN78 MYD8B Mark 01-Sep-20
    MAN78 MYD8B Mark 15-Sep-20
    I am eager to clarify if anything is unclear. Thank you in advance for your support.

    Best wishes,
    Ami
Working...
X