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

ParanormalDensityPlot.png

 

With the help of code snipped from Stephen Mistler's 2014 Producing Normal Density Plots With Shading, here's a quick SAS ODS Graphics takeoff on Andrew Heiss's 2018 R/ggplot Paranormal Distribution. Happy Halloween, all!


Btw, it's probably worth mentioning that if you need a density plot - but don't need to make it look like a crudely-drawn Halloween ghost costume - SAS ODS Graphics' DENSITY statement makes things a breeze!

 

SAS CODE

* Fun w/SAS ODS Graphics: "Para-Normal" Density Plot
  See Stephen Mistler's Producing Normal Density Plots With Shading at blogs.sas.com/content/sastraining/2014/06/10/producing-normal-density-plots-with-shading
  and Andrew Heiss's R/ggplot Paranormal Distribution at https://twitter.com/andrewheiss/status/1057682358135021568;
  
data pdf;                       * Points for density plot;
retain lower 0;                 * Used to create area plot;
do X=-5 to 5 by .001;           * Generate points to plot;
  PDF=pdf("Normal", x, 0, 1.5); * SAS probability distribution function (normal);
  output;
end;

data EyesMouth;                 * Points for eyes/mouth of "ghost";
circle=unicode('\u25CF');       * Unicode filled circle for eyes/mouth;
input x2 y2 size;               * Coordinates/sizes for eyes/mouth (eyes smaller than mouth);
cards;
-.55  .2 1 Left Eye
 .55  .2 1 Right Eye
   0 .15 3 Mouth
;
data Ghost;                      * Merge data together to create our "ghost";
set pdf EyesMouth;
                                 * Plot the "ghost";
ods graphics / ANTIALIASMAX=10100; * Band plot (density curve) + text plot (eyes/mouth);                              
proc sgplot data=ghost noautolegend nowall noborder;
title height=18pt "PARANORMAL DENSITY PLOT";
styleattrs backcolor=orange;     * Pumpkin-ish color;
band x=x lower=lower upper=pdf / fillattrs=(color=white); * Ghost body is band plot (shaded normal density plot);
text x=x2 y=y2 text=circle / textattrs=(family="Arial Unicode MS") /* Plot ghost eyes/mouth (circles) */
                              sizemin=32pt sizemax=96pt sizeresponse=size;
xaxis display=(nolabel noline noticks) grid gridattrs=(color=white) valueattrs=(color=white); * Use white grid lines, suppress axis line;
yaxis display=(nolabel noline noticks) grid gridattrs=(color=white) valueattrs=(color=white) min=0 offsetmin=.01 offsetmax=.01;
inset "HAPPY HALLOWEEN!" / position=bottom textattrs=(size=14pt weight=bold); * Halloween greeting at bottom;
run;

 

 

3 REPLIES 3
MichelleHomes
Meteorite | Level 14

What a ghoulish and great graph! Clever use of unicode characters as text for the eyes & mouth.  Smiley Happy

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

Twitter user ProcStream ("PROC SPPooky" for the season) shared this variation.

 

cc.jpg

 

EIH3GmnXYAMtwAF.jpg

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
tomrvincent
Rhodochrosite | Level 12

I guess it doesn't work with Linux.

 

image.png

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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