Dear members,
I'm new to the forum and posted an inquiry yesterday. Apologies for any confusion; it seems I didn't follow the forum rules, and there was a mistake in posting my data.
To simplify things, I've attached the correct data below.
I am looking for someone to help me with the following coding problem:
At the beginning of each month in a given team:
1st, I would like to calculate for each player 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, the share of max goal against a single player counts in a total scores for each player as (2nd/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.
Any guidance or support would be greatly appreciated.
I'm new to the forum and posted an inquiry yesterday. Apologies for any confusion; it seems I didn't follow the forum rules, and there was a mistake in posting my data.
To simplify things, I've attached the correct data below.
I am looking for someone to help me with the following coding problem:
At the beginning of each month in a given team:
1st, I would like to calculate for each player 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, the share of max goal against a single player counts in a total scores for each player as (2nd/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:
* Example generated by -dataex-. For more info, type help dataex clear input str5(team player) str7 ScoredAgainst int GameDate "AR010" "BKX9M" "Jesen" 21808 "AR010" "BKX9M" "Mark" 21865 "AR010" "BKX9M" "Jesen" 21897 "AR010" "BKX9M" "Jesen" 21915 "AR010" "BKX9M" "Jesen" 21926 "AR010" "BKX9M" "Jesen" 21947 "AR010" "BKX9M" "Jesen" 21975 "AR010" "BKX9M" "Mark" 21986 "AR010" "BKX9M" "Parker" 22047 "AR010" "KCH6W" "Jesen" 21808 "AR010" "KCH6W" "Parker" 21992 "AR010" "KCH6W" "Mark" 22035 "AR010" "KCH6W" "Parker" 22047 "AR010" "KCH6W" "Parker" 22067 "AR010" "KCH6W" "Parker" 22081 "AR010" "KCH6W" "Parker" 22108 "AR010" "GHBEO" "Parker" 22002 "AR010" "GHBEO" "Parker" 22017 "AR010" "GHBEO" "Parker" 22047 "MAN78" "NMD8B" "Mark" 21806 "MAN78" "NMD8B" "Mark" 21870 "MAN78" "NMD8B" "Mark" 21884 "MAN78" "NMD8B" "Parker" 21897 "MAN78" "NMD8B" "William" 21926 "MAN78" "NMD8B" "Mark" 21942 "MAN78" "NMD8B" "Mark" 22048 "MAN78" "NMD8B" "Mark" 22150 "MAN78" "NMD8B" "Mark" 22159 "MAN78" "NMD8B" "Mark" 22173 "MAN78" "MYD8B" "Mark" 21942 "MAN78" "MYD8B" "Mark" 22048 "MAN78" "MYD8B" "Mark" 22150 "MAN78" "MYD8B" "Mark" 22159 "MAN78" "MYD8B" "Mark" 22173 end format %tddd-Mon-YY GameDate
Comment