Data visualization with SAS programming

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

Reply
Highlighted
Frequent Contributor
Frequent Contributor
Posts: 75

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

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;

 

SAS Super FREQ
Posts: 1,118

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/

 

 

SAS Super FREQ
Posts: 1,118

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

[ Edited ]
SAS Super FREQ
Posts: 3,547

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: 634

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 Smiley Happy

Ask a Question
Discussion stats
  • 4 replies
  • 1479 views
  • 26 likes
  • 4 in conversation