## Fun with SAS ODS Graphics: Total eclipse of the sun edition

Solved
Frequent Contributor
Posts: 81

# Fun with SAS ODS Graphics: Total eclipse of the sun edition

With Monday nearing, solar eclipse fever is hitting new heights. So, figured I'd follow Robert Allison’s lead and join the frenzy with some eclipse-themed SAS code. Here's my quick SAS ODS Graphics take on solar eclipse time-lapse photography - put on your ISO certified glasses before viewing the output, kids!

``````* Fun w/SAS ODS Graphics: Solar Eclipse "Time-Lapse" (SGPANEL + BUBBLE Plots)

Inspired by forum.timescapes.org/phpBB3/viewtopic.php?f=4&t=7775;

data eclipse;                                /* Generate points for sun/moon */
do frame=1 to 11;                            /* At 11 different times/locations */
sunX=.5; sunY=.5; sz=50; output;           /* Sun plotted at constant position in frame */
sunX=.; sunY=.;
if frame<=6 then                           /* Sun goes behind moon in first 6 frames */
moonX=.5+(6-frame)*(.775/5);
else                                       /* Sun emerges from behind moon in last 5 frames */
moonX=.5-(frame-6)*(.775/5);
moonY=.5; sz=40; output;                   /* Make moon slightly smaller bubble than sun */
moonX=.; moonY=.;
sz=1; output;                              /* "Dummy" points with size=1 make sun/moon bigger */
end;

ods listing gpath='/folders/myfolders';      /* Use SGPANEL to plot frames in one image */
ods graphics on / reset antialias width=10in height=1in imagename="ECLIPSE";

proc sgpanel data=eclipse noautolegend;      /* "Time-lapse" is 1x11 panel of bubble plots */
styleattrs backcolor=black wallcolor=black;
rowaxis display=none;
colaxis display=none values=(0 to 1) min=0 max=1 offsetmin=0 offsetmax=0;
run;``````

Accepted Solutions
Highlighted
Solution
‎10-04-2017 10:47 AM
SAS Super FREQ
Posts: 1,199

## Re: Fun with SAS ODS Graphics: Total eclipse of the sun edition

[ Edited ]

Editor's note: This is a great addition to the original post.

Building on Ted's work:

http://blogs.sas.com/content/graphicallyspeaking/2017/08/20/fun-ods-graphics-eclipse-animation/

All Replies
SAS Super FREQ
Posts: 1,199

## Re: Fun with SAS ODS Graphics: Total eclipse of the sun edition

[ Edited ]

Awesome, TC.  Great demonstration of using SG procedures for non-standard visuals.  You could probably use FRAME as the BY variable with SGPLOT, and create an animated GIF or SVG.

Example code for animation using printerpath:  http://blogs.sas.com/content/graphicallyspeaking/2013/05/23/animation-using-sgplot/

Highlighted
Solution
‎10-04-2017 10:47 AM
SAS Super FREQ
Posts: 1,199

## Re: Fun with SAS ODS Graphics: Total eclipse of the sun edition

[ Edited ]

Editor's note: This is a great addition to the original post.

Building on Ted's work:

http://blogs.sas.com/content/graphicallyspeaking/2017/08/20/fun-ods-graphics-eclipse-animation/

SAS Super FREQ
Posts: 3,839

## Re: Fun with SAS ODS Graphics: Total eclipse of the sun edition

Great, Sanjay, but now I'll go blind because I looked at your animation without eye protection. Shame on you for not posting a warning!

PROC Star
Posts: 968

## Re: Fun with SAS ODS Graphics: Total eclipse of the sun edition

Very very cool @tc and @Sanjay_SAS. I am located in Denmark, so no eclipse for me, but yours will do

☑ This topic is solved.