BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

ECLIPSE.png

 

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;
panelby frame / rows=1 columns=11 onepanel noheader noheaderborder noborder;
bubble x=sunX y=sunY size=sz / colormodel=(yelloworange) colorresponse=sunX dataskin=sheen bradiusmax=50;
bubble x=moonX y=moonY size=sz / colormodel=(black) colorresponse=moonX dataskin=sheen bradiusmax=50;
rowaxis display=none; 
colaxis display=none values=(0 to 1) min=0 max=1 offsetmin=0 offsetmax=0;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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/

 

Added some stars.

 Eclipse_Stars_Anim.gif

 

View solution in original post

4 REPLIES 4
Jay54
Meteorite | Level 14

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/

 

 

Jay54
Meteorite | Level 14

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/

 

Added some stars.

 Eclipse_Stars_Anim.gif

 

Rick_SAS
SAS Super FREQ

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!

PeterClemmensen
Tourmaline | Level 20

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 13303 views
  • 34 likes
  • 4 in conversation