Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

undefined

 

Just registered for SAS Global Forum 2017 at Walt Disney World in Orlando, so to mark the occasion, here's a quick SAS ODS Graphics take on the Mickey Mouse Template provided by Disney Family. Hope to M-I-C some of you in April!

 

* SAS ODS Graphics take on Mickey Mouse silhouette from family.disney.com/craft/mickey-mouse-template/;

data mickey;                                             * Generate chart data (grab coordinates from MS-Paintbrush);
imageSizeX=680; imageSizeY=593;                          * Image template width/height (px);

faceOriginX=340; faceOriginY=366;                        * Face points (circle);
faceTopCenterX=340; faceTopCenterY=147;
faceRadius=faceOriginY-faceTopCenterY;                   * Calculate face radius;
label="SGF 2017";                                        * Label for face;

leftEarOriginX=131; leftEarOriginY=131;                  * Left ear points (ellipse);
leftEarLeftCenterX=40; leftEarLeftCenterY=238;
leftEarTopCenterX=43; leftEarTopCenterY=49;              * Calculate left ear semimajor/semiminor lengths, slope;
leftEarSemiMajor=sqrt((leftEarOriginX-leftEarLeftCenterX)**2+(leftEarOriginY-leftEarLeftCenterY)**2);
leftEarSemiMinor=sqrt((leftEarOriginX-leftEarTopCenterX)**2+(leftEarOriginY-leftEarTopCenterY)**2);
leftEarSlope=-(leftEarLeftCenterY-leftEarOriginY)/(leftEarLeftCenterX-leftEarOriginX);

rightEarOriginX=551; rightEarOriginY=139;                * Right ear points (ellipse);
rightEarLeftCenterX=462; rightEarLeftCenterY=35;
rightEarTopCenterX=637; rightEarTopCenterY=52;           * Calculate right ear semimajor/semiminor lengths, slope;
rightEarSemiMajor=sqrt((rightEarOriginX-rightEarLeftCenterX)**2+(rightEarOriginY-rightEarLeftCenterY)**2);
rightEarSemiMinor=sqrt((rightEarOriginX-rightEarTopCenterX)**2+(rightEarOriginY-rightEarTopCenterY)**2);
rightEarSlope=-(rightEarLeftCenterY-rightEarOriginY)/(rightEarLeftCenterX-rightEarOriginX);

faceOriginY=imageSizeY-faceOriginY;                      * Adjust y-coordinates from top=0 to bottom=0;
leftEarOriginY=imageSizeY-leftEarOriginY;
leftEarTopCenterY=imageSizeY-leftEarTopCenterY;
rightEarOriginY=imageSizeY-rightEarOriginY;
rightEarTopCenterY=imageSizeY-rightEarTopCenterY;        

ods listing image_dpi=300 gpath='/folders/myfolders';    * Plot Mickey Mouse silhouette;
ods graphics on / reset antialias width=5in height=5in imagename="MICKEY";
proc template;
 define statgraph ellipseparm;
 begingraph; 
   entrytitle "M-I-C...SEE YOU REAL SOON!";     
   layout overlayequated /  
     xaxisopts=(display=(line ticks tickvalues) offsetmin=0.05 offsetmax=0.05)
     yaxisopts=(display=(line ticks tickvalues) offsetmin=0.05 offsetmax=0.05);
     ellipseparm xorigin=faceOriginX yorigin=faceOriginY              /* FACE */      
                 semimajor=faceRadius semiminor=faceRadius slope=0 /
                 fillattrs=(color=black) display=(fill);
     ellipseparm xorigin=leftEarOriginX yorigin=leftEarOriginY        /* LEFT EAR */ 
                 semimajor=leftEarSemiMajor semiminor=leftEarSemiMinor slope=leftEarSlope /
                 fillattrs=(color=black) display=(fill);
     ellipseparm xorigin=rightEarOriginX yorigin=rightEarOriginY      /* RIGHT EAR */ 
                 semimajor=rightEarSemiMajor semiminor=rightEarSemiMinor slope=rightEarSlope /
                 fillattrs=(color=black) display=(fill);
     textplot x=faceOriginX y=faceOriginY text=label /                /* LABEL */
                 position=center textattrs=(color=white size=28pt weight=bold);
   endlayout;
  endGraph;
 end;
run;
proc sgrender data=mickey template=ellipseparm;
run;

A NOTE ON DETERMINING POINT COORDINATES
So, was it difficult to find the coordinates of the points needed for the above chart? Not at all! Just cut-and-pasted the Disney-provided Mickey Mouse Template into Microsoft Paintbrush, drew a few lines to bisect the "face" and "ears", and hovered over the 8 needed points (starred below) to display the coordinates in the status bar.

 

undefined

2 REPLIES 2
MichelleHomes
Meteorite | Level 14

Awesome as always @tc!!!

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 2 replies
  • 2945 views
  • 4 likes
  • 3 in conversation