60 likes | 256 Views
Chapter 3 Supplement. Self-joins Using PROC SQL. Self-Joins. Self-joins, or Reflexive Joins are used to compare values within a data set Examples typically use equality operations to create a join. 2011 SEC Football Scores. Self-Joins.
E N D
Chapter 3 Supplement Self-joins Using PROC SQL
Self-Joins • Self-joins, or Reflexive Joins are used to compare values within a data set • Examples typically use equality operations to create a join
Self-Joins • Note that USC’s winning score on November 12 matches Mississippi State’s losing score on November 19 • We can record all such instances using a reflexive join • The reflexive join can look like an outer union
Self-Join Syntax proc sql; select winner.wscore, winner.date, winner.wteam, loser.date, loser.lteam from secscores as winner, secscores as loser where winner.wscore=loser.lscore; quit;
Self-Join Syntax • We do not have to use equality operators: proc sql; select winner.wscore, winner.date, winner.wteam, loser.date, loser.lteam from secscores as winner, secscores as loser where winner.wscorelt loser.lscore; quit;