Here's a "New Year's Eve Ball Drop" inspired by the blinking lights that graced the front panels of vintage computers. Happy New Year, all!
* Fun w/SAS ODS Graphics: New Year's Eve 4-Bit Boolean Ball Drop (Animated GIF Bubble Chart);
data lights; /* Generate "vintage computer front panel lights" */
retain size 1; /* All lights are same size */
do frame=10 to 0 by -1; /* Need a 10-second NYE countdown */
do y=10 to 0 by -1;
lights=put(y,binary4.); /* Convert seconds counter to string of 1's and 0's */
do x=1 to 4;
color=((frame=y) & (substr(lights,x,1)='1')); /* Turn on lights on/off to reflect # of seconds left */
output;
end;
end;
end;
%macro genframes; /* Generate frames for NYE ball drop countdown animation */
%do frame=10 %to 0 %by -1; /* One frame for each second */
options animduration= %if &frame=10 or &frame=0 %then 2; %else 1;; /* Display first and last frames for 2 seconds, all other for 1 second */
%if &frame>0 %then %let year=2022; %else %let year=2023; /* Change year from 2022 to 2023 on last frame */
proc sgplot data=lights(where=(frame=&frame)) noautolegend aspect=1.25 noborder nowall pad=0 subpixel; /* Generate countdown! */
styleattrs backcolor=black; /* Midnight black background */
bubble x=x y=y size=size / fill /* Generate on (red) and off (black) lights */
dataskin=pressed nooutline colormodel=(black red) colorresponse=color bradiusmin=.14in bradiusmax=.15in;
xaxis display=(nolabel noline noticks) values=(.75 1 2 3 4 4.25) valuesdisplay=(" " "8" "4" "2" "1" " ") valueattrs=(color=white weight=bold); /* Display powers of 2 on x-axis */
yaxis display=(noline noticks) label="&year" values=(10 to 0 by -1) labelattrs=(color=white weight=bold size=72pt) valueattrs=(color=white weight=bold); /* Display year and seconds on y-axis */
run;
%end;
%mend;
ods graphics / imagefmt=GIF width=5in height=5in antialias; /* Record images */
options papersize=('5 in', '5 in') animduration=2 animloop=yes animoverlay printerpath=gif animation=start nodate nonumber;
ods printer file='~/newyear/countdown.gif'; /* Animated GIF filename */
%genframes; /* Generate frames */
options printerpath=gif animation=stop; /* Stop recording images */
ods printer close;
By superde1uxe - https://www.flickr.com/photos/superde1uxe/1914344040/sizes/o/, CC BY 2.0, https://commons.wikimedia.org/w/index.php?curid=7579435
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.