BookmarkSubscribeRSS Feed
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

grammys.png

 

Grammy Awards are tonight, so here's a short SAS ODS Graphics program to chart the nominees' chances of winning (input data from Yahoo, full output for all 37 categories on GitHub).

 

* Fun With SAS ODS Graphics: 2024 Grammy Nominee Odds
  Data soure: yahoo.com/entertainment/2024-grammy-predictions-official-odds-150050388.html
  Odds-to-probability calc from en.wikipedia.org/wiki/Mathematics_of_bookmaking;
  
data nominees;                                                          * Read in data;
length probability 8. category nominee odds : $ 255.; retain minx .005 maxX .295 category;
infile "/home/ted.conway/GrammyOdds.txt" lrecl=255 truncover;
input;
if ^index(_infile_,'—') then do; seq=0; category=_infile_; delete; end; * Category Header?; 
seq+1;                                                                  * Process nominee odds;
seqx=put(seq,z2.);                                                      * Maintain nominee sequence order;
nominee=scan(_infile_,1,'—');                                           * Grab nominee and/or recording; 
odds=scan(_infile_,2,'—');                                              * Grab fractional odds;
probability=scan(odds,2,'/')/(scan(odds,1,'/')+scan(odds,2,'/'));       * Convert to probability (0-1);
output;

ods graphics / width=16in height=9in noborder outputfmt=svg;
proc sgpanel data=nominees noautolegend des="2024 Grammy Awards";       * Draw charts for 9 categories in a 3x3 grid on each page (37 categories);   
panelby category / headerattrs=(weight=bold color=black) novarname nowall noheaderborder noborder rows=3 columns=3 headerbackcolor=white sparse skipemptycells; 
hbarparm category=seqx response=probability / nooutline fillattrs=(color=cXA8D8FF); * Bar chart with light blue bars;
text x=minX y=seqx text=nominee / position=right strip contributeoffsets=none textattrs=(size=9pt color=black) splitchar='|' splitpolicy=splitalways; * Text plot of nominee and/or recording (left-aligned over bars);
text x=maxX y=seqx text=odds / position=left strip contributeoffsets=none textattrs=(size=9pt color=black); * Text plot showing fractional odds (to the right of nominees);
rowaxis display=(nolabel novalues noticks noline);                      * Suppress most axis info, but show probabilities; 
colaxis display=(nolabel noticks) values=(0 .1 .2 .3) valuesdisplay=('0%' '10%' '20%' '30%') grid valueattrs=(size=8pt);
run;

 

DETAIL VIEW

grammysalbums.png

  

CORRESPONDING DATA SNIPPET

ALBUM OF THE YEAR
Taylor Swift, "Midnights" — 5/1
Boygenius, "The Record" — 5/1
SZA, "SOS" — 11/2
Jon Batiste, "World Music Radio" — 7/1
Olivia Rodrigo, "Guts" — 17/2
Lana Del Rey, "Did You Know That There's a Tunnel Under Ocean Blvd" — 17/2
Miley Cyrus, "Endless Summer Vacation" — 19/2
Janelle Monae, "The Age of Pleasure" — 10/1
...

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 0 replies
  • 457 views
  • 7 likes
  • 1 in conversation