Jared Goff was the most important quarterback (the "QB1") on the Los Angeles Rams in 2018. The second-most important wide receiver on the Los Angeles Rams in 2018, statistically speaking, was Brandin Cooks (he was the "WR2"). In 2017, Brandin Cooks played for the New England Patriots. His top quarterback in 2017 on the Patriots, Tom Brady, threw for 32 touchdowns that season. What I want to do is create a variable called 'wr2_qb1_pass_td_lag' for Jared Goff in 2018 that gives the number of touchdowns Goff's WR2's previous QB1 threw for (i.e. wr2_qb1_pass_td_lag = 32 if (player == "Jared Goff" & year == 2018)).
My best attempt to do this so far has been:
Code:
egen wr2_qb1_pass_td_lag = max(cond(pos_rank_on_team == 2 & position == "WR"), qb1_pass_td_lag, .), by(team year)
Can anyone help me out here? I'd really appreciate it!
0 Response to Difficulty generating a conditional variable
Post a Comment