A short ODS Graphics program that produces a series plot showing how the amazing Katie Ledecky led all at every split from start to finish enroute to winning a gold medal Saturday in the 800m freestyle for the fourth consecutive Olympics!
Btw, here's an old ODS Graphics vector + scatter + xaxistable plot take on Ledecky's 2016 victory in the 800m freestyle.
* Fun With SAS ODS Graphics: Katie Ledecky Wins 9th Gold With Four-Peat in 800m Freestyle
Data: olympics.com/en/paris-2024/results/swimming/women-s-800m-freestyle/fnl-000100--;
proc import file="~/WomensSwimming800mFreestyle.xlsx" out=swimmers dbms=xlsx replace; * Get data;
proc sql; * Prep data for charting;
create table swimmers2 as
select s.*,
put(rank,1.)||'. '||trim(s.swimmer)||' ('||trim(country)||'), '||put(maxtime,mmss7.2) as name,
ifn(distance='Finish',800,input(compress(distance,'m'),3.)) as meters
from swimmers s
join (select swimmer, max(time) as maxtime from swimmers group by 1) s2 on s.swimmer=s2.swimmer;
* Calc time behind leader at splits;
create table swimmers3 as
select s.name, s.meters, mintime-time as time_behind from swimmers2 s
join (select meters, min(time) as mintime from swimmers2 group by 1) s2 on s.meters=s2.meters
union all /* Add a starting point for all swimmers (t=0) */
select distinct name, 0 as meters, 0 as time_behind from swimmers2
order by name, meters, time_behind;
ods graphics / noborder height=6in width=8in; * Let's chart the swimmers' times!;
proc sgplot nowall noborder noautolegend; * Series plot of time behind leader at each split for all swimmers;
title justify=left "PARIS 2024 OLYMPICS WOMEN'S 800M FREESTYLE";
series x=meters y=time_behind / group=name curvelabel curvelabelloc=outside;
scatter x=meters y=time_behind / markerattrs=(size=0pt) x2axis y2axis; * Make distance also display at top of chart (x2axis);
xaxis display=(noline noticks nolabel) grid type=discrete values=(0 to 800 by 50) valueattrs=(size=8pt);
x2axis display=(noline noticks nolabel) type=discrete values=(0 to 800 by 50) valueattrs=(size=8pt);
yaxis display=(noline noticks) label="SECONDS BEHIND" valueattrs=(size=8pt);
y2axis display=none;
run;
DATA SAMPLE
RANK | SWIMMER | COUNTRY | DISTANCE | TIME | PLACE | SPLIT |
1 | LEDECKY Katie | USA | 50m | 00:27.6 | 1 | |
1 | LEDECKY Katie | USA | 100m | 00:57.4 | 1 | 29.8 |
1 | LEDECKY Katie | USA | 150m | 01:27.9 | 1 | 30.44 |
1 | LEDECKY Katie | USA | 200m | 01:58.7 | 1 | 30.84 |
1 | LEDECKY Katie | USA | 250m | 02:29.7 | 1 | 30.97 |
1 | LEDECKY Katie | USA | 300m | 03:00.9 | 1 | 31.19 |
1 | LEDECKY Katie | USA | 350m | 03:32.1 | 1 | 31.18 |
1 | LEDECKY Katie | USA | 400m | 04:03.2 | 1 | 31.15 |
1 | LEDECKY Katie | USA | 450m | 04:34.4 | 1 | 31.24 |
1 | LEDECKY Katie | USA | 500m | 05:05.8 | 1 | 31.34 |
1 | LEDECKY Katie | USA | 550m | 05:37.0 | 1 | 31.2 |
1 | LEDECKY Katie | USA | 600m | 06:08.0 | 1 | 31.03 |
1 | LEDECKY Katie | USA | 650m | 06:38.9 | 1 | 30.9 |
1 | LEDECKY Katie | USA | 700m | 07:09.8 | 1 | 30.88 |
1 | LEDECKY Katie | USA | 750m | 07:40.7 | 1 | 30.9 |
1 | LEDECKY Katie | USA | Finish | 08:11.0 | 1 | 30.35 |
Btw, at Paris in 2024, Ledecky's winning time of 8:11.04 was 1.25 seconds faster than the silver medalist. Ledecky won gold at the Tokyo 2020 Olympics by a similar margin (1.25 seconds) with her 8:12.57 time. At the Rio 2016 games, Ledecky's winning time of 8:04.79 - a world record that still stands today - was an incredible 11.38 seconds faster than the silver medalist. And at London in 2012, Ledecky bested the silver medalist by a margin of 4.13 seconds with an 8:14.63 performance. Wikipedia has much more on Ledecky and the world record progression in the 800 metres freestyle.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: