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

HappyNewYear.gif

 

A quick black-and-white ODS Graphics take on the Times Square New Year's Eve ball drop (hat tip to Rick Wicklin for the BY-statement trick!). Happy New Year's!

 

CODE

* Fun w/SAS ODS Graphics: B&W New Year's Eve Ball Drop;
 
*==> Generate and render data for frames showing ball dropping w/countdown timer;

data HappyNewYear;                                     * Generate points/text for ball drop & countdown timer;
x=.5; x1=.5;                                           * X-values of ball, countdown text are constant;
x1=.5; y1=.5; y2016=2016;                              * Coordinates and label for countdown timer;
do frameid=1 to 0 by -.01;                             * Generate data for frames (ball position + timer text);
  if frameid>.0001 then text=compress(put(ceil(frameid*10),2.)); else text='';
  y=frameID;
  r=50;                                                * Relative size of ball for bubble plot;  
  output; 
  y=.; r=1; output;                                    * Generate small "dummy" point to make ball bigger; 
end;
run;

options nobyline;                                      * Animated GIF initialization;
ods _all_ close;
options papersize=('5 in', '5 in') printerpath=gif animation=start 
        nodate nonumber animloop=YES animduration=.1 NOANIMOVERLAY ;
ods printer file='/folders/myfolders/HappyNewYear/HappyNewYear.gif';
ods graphics / width=5in height=5in imagefmt=GIF border=off;

proc template;                                         * Display ball (bubbleplot) & countdown timer (textplot);
define statgraph newyearplot1;
begingraph / opaque=true border=false drawspace=layoutpercent backgroundcolor=black;
  layout overlayequated / equatetype=square border=false  
         WALLDISPLAY=NONE commonaxisopts=(viewmin=-.15 viewmax=1.15 tickvaluelist=(-.15 1.15)) 
         xaxisopts=(display=none OFFSETMAX=0 OFFSETMIN=0) yaxisopts=(display=none OFFSETMAX=0 OFFSETMIN=0);
    textplot x=x1 y=y1 text=text / position=center textattrs=(size=232pt color=grey) contributeoffsets=none;     
    bubbleplot x=x y=y size=r / datalabel=y2016 datalabelposition=center 
               datalabelattrs=(color=black weight=bold size=20pt)
               dataskin=sheen colormodel=(WHITE) colorresponse=x bubbleradiusmax=40;        
  endlayout;
endgraph;
end;

proc sgrender data=happynewyear template=newyearplot1; * Generate one frame for each position of ball;
by frameID notsorted;

*==> Generate and render data for Happy New Year! frames;

data happynewyear2;                                    * Generate points/text;
x1=.5; y1=.5; text1="Happy*New Year!";
x2=.5; y2=0;  text2="2017"; 

%macro genframes(duration=,backlight=);                * Vary backlighting/duration to make words "flash";
options animduration=&duration;

proc template;
define statgraph newyearplot2;
begingraph / opaque=true border=false drawspace=layoutpercent backgroundcolor=black;
  layout overlayequated / equatetype=square border=false  
         WALLDISPLAY=NONE commonaxisopts=(viewmin=-.15 viewmax=1.15 tickvaluelist=(-.15 1.15)) 
         xaxisopts=(display=none OFFSETMAX=0 OFFSETMIN=0) yaxisopts=(display=none OFFSETMAX=0 OFFSETMIN=0);
    textplot x=x1 y=y1 text=text1 / position=top backlight=&backlight splitchar='*' splitpolicy=splitalways
                                    textattrs=(size=42pt weight=bold) contributeoffsets=none;
    textplot x=x2 y=y2 text=text2 / position=center backlight=&backlight splitchar='*' splitpolicy=splitalways
                                    textattrs=(size=42pt weight=bold) contributeoffsets=none;             
  endlayout;
endgraph;
end;

proc sgrender data=happynewyear2 template=newyearplot2;
run;
%mend;

%genframes(duration=.5,backlight=1);                  * Alternate bright/dim for "flashing" effect;
%genframes(duration=.5,backlight=.5);
%genframes(duration=.5,backlight=1);
%genframes(duration=.5,backlight=.5);
%genframes(duration=.5,backlight=1);
%genframes(duration=.5,backlight=.5);
%genframes(duration=3,backlight=1);

options printerpath=gif animation=stop;             * Wrap-up animated GIF creation;                         
run;
ods printer close;
4 REPLIES 4
ChrisHemedinger
Community Manager

Thanks for squeezing in one more cool ODS Graphics trick, @tc! Happy New Year!

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
MichelleHomes
Meteorite | Level 14

Nice count down @tc! Will this be your next dataviz? www.linkedin.com/hp/update/6221188723963359232

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

It is a nice effect - perhaps I should submit a SASware Ballot idea for a CIRCULARDOTPLOT SGPLOT statement.  🙂

LeRoyBessler
Obsidian | Level 7

Another nice piece of work by Ted, BUT . . .

what happened to the Leap Second?

Or is it added to 2017 AFTER the ball drop completes?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 3091 views
  • 15 likes
  • 4 in conversation