Announcement

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

  • Generating a new variable

    I am working with play-by-play data on the NFL.

    In my dataset, I have a variable named GameID, a unique identifier for every game, a variable named Quarter, for the quarter that a play takes place in, a variable called Yards, the Yards gained in a play, and finally Run, a dummy variable that equals 1 if the play was a run.

    I wish to create a new variable that gives the average yards per rush in each quarter for a given game. Help on how I can create such a variable would be greatly appreciated.

    Thanks in advance

  • #2
    Hi Alex,

    If I understand correctly you want to average yards per run per quarter per game?

    I believe all you need to do is something along the lines of the following:

    Code:
    bysort GameID Quarter Run: egen avgYards = mean(Yards)
    Hopefully this works for you!

    Comment

    Working...
    X