This is a little bit late for American Thanksgiving, but I just noticed this program shared from @tc on SAS-L and on Twitter. He used some plot point data from http://math-aids.com to create a fun turkey image with -- of all things -- a SCATTER plot statement in PROC SGPLOT.
Here's the complete program, data included. It can run in SAS University Edition or SAS Enterprise Guide (as well as in Base SAS, of course).
/* Program courtesy of Ted Conway on SAS-L */
/* Data plot points from http://math-aids.com */
data TomTurkey(keep=shapeID x y);
length shapeID $ 20. x 8 y 8;
retain shapeID;
infile datalines4;
input;
if _infile_=:'Shape' then
shapeID=_infile_;
else
do;
i=1;
do while(scan(_infile_, i, '(), ')^='');
x=scan(_infile_, i, '(), ');
y=scan(_infile_, i+1, '(), ');
i+2;
output;
end;
end;
datalines4;
Shape 1
(-3,-11) , (-3.5,-12.5) , (-4,-12) , (-4.5,-12.5) , (-4,-13) , (-3,-14) , (-2,-15.5) , (-1.5,-16) , (-1.5,-15.5) , (-2,-14)
(-1,-15) , (0,-15.5) , (-.5,-14.5) , (-1,-14) , (0,-14.5) , (0,-14) , (-.5,-13.5) , (-2,-13) , (-2.5,-12.5) , (-1.5,-11.5) , (-3,-11)
Shape 2
(-1.5,-11.5) , (0,-11.5) , (.5,-12) , (.5,-13) , (-.5,-12.5) , (-.5,-13.5) , (0,-14) , (1.5,-15) , (2,-16) , (2.5,-15.5) , (2,-15)
(3,-15.5) , (3.5,-15.5) , (3.5,-15) , (2,-14.5) , (3,-14.5) , (3.5,-14.5) , (3.5,-14) , (2,-13.5) , (1,-13.5) , (1.5,-12.5) , (.5,-12)
Shape 3
(1.5,-12.5) , (2.5,-11.5) , (4.5,-11.5) , (6.5,-10) , (7.5,-8.5) , (9,-7) , (9.5,-5.5) , (10.5,-4)
(10.5,-3) , (10,-2.5) , (8.5,-2) , (9.5,-3.5) , (9.5,-5.5)
Shape 4
(-3,-11) , (-4,-10) , (-4,-8.5) , (-5.5,-7) , (-4,-8) , (-3,-8) , (-1,-7.5) , (2,-6) , (4.5,-4) , (5.5,-1.5) , (7,-2.5) , (8.5,-2)
Shape 5
(-5.5,-7) , (-6.5,-6.5) , (-7,-5.5) , (-8,-5) , (-8,-3.5) , (-9,-3.5) , (-9.5,-3) , (-10.5,-3) , (-10.5,-4)
(-10,-5.5) , (-9,-6.5) , (-8,-6.5) , (-7,-5.5)
Shape 6
(-10.5,-3) , (-11.5,-2.5) , (-12,-1) , (-11,1) , (-9,1) , (-10.5,0) , (-11,-1) , (-10.5,-2) , (-9.5,-2) , (-9.5,-3)
Shape 7
(-9,1) , (-8,1.5) , (-8,0) , (-7,-.5) , (-7,-1.5) , (-6,-2.5) , (-5,-2.5) , (-5,-3.5) , (-4,-4.5)
(-3,-4.5) , (-3.5,-5.5) , (-2,-6) , (-1.5,-7) , (-1,-7.5)
Shape 8
(-8,1.5) , (-7,2) , (-6,2.5) , (-3.5,2.5) , (-4,2) , (-4,1) , (-3,.5) , (-3.5,0) , (-3,-1) , (-2,-1)
(-2.5,-2) , (-2,-3) , (-.5,-3) , (-1,-4) , (0,-5) , (.5,-4.5) , (1,-5.5) , (2,-6)
Shape 9
(-3.5,2.5) , (-1.5,2.5) , (-1.5,2.5) , (.5,2) , (1.5,1.5) , (2.5,1) , (3.5,.5) , (5,-1) , (5.5,-1.5)
Shape 10
(-11,1) , (-12,2) , (-11.5,4) , (-10.5,5) , (-8.5,4) , (-6,2.5)
Shape 11
(-10.5,5) , (-10.5,6) , (-10,7.5) , (-9,8.5) , (-8,8.5) , (-6,6) , (-3.5,2.5)
Shape 12
(-8,8.5) , (-7.5,10) , (-6.5,10.5) , (-5.5,11) , (-4.5,10.5) , (-3.5,7.5) , (-2.5,5) , (-1.5,2.5)
Shape 13
(-4.5,10.5) , (-4,11.5) , (-3,12) , (-2,12.5) , (-1,12) , (-.5,11.5) , (-.5,7) , (-.5,2.5)
Shape 14
(-.5,11.5) , (0,12.5) , (1,12.5) , (2.5,12) , (3.5,11) , (2.5,8) , (.5,2)
Shape 15
(3.5,11) , (5,11) , (6,10.5) , (7,9) , (4,5) , (1.5,1.5)
Shape 16
(7,9) , (8.5,8.5) , (9.5,7) , (8,7.5) , (6.5,6.5) , (6,5) , (6,3.5) , (2.5,1)
Shape 17
(6,3.5) , (6,1) , (3.5,.5)
Shape 18
(6,1) , (5.5,0) , (5,-1)
Shape 19
(9.5,7) , (10.5,6.5) , (11,5) , (9.5,5) , (8,3) , (7.5,2) , (8,1.5) , (8.5,1.5) , (9,2.5) , (9.5,3.5)
(9.5,4.5) , (10.5,4.5) , (11,4) , (11,5)
Shape 20
(8.5,-2) , (8,.5) , (8,1.5)
Shape 21
(9.5,3.5) , (10,3) , (11.5,2.5) , (11,4)
Shape 22
(9.5,1.5) , (10.5,1.5) , (11.5,2.5) , (10,3) , (9.5,2.5) , (9.5,1.5) , (9,1) , (8,.5)
Shape 23
(10.5,1.5) , (11.5,1) , (11.5,0) , (11,-2) , (10,-2.5)
Shape 24
(8.5,6) , (8,5.5) , (8.5,5) , (9,5.5) , (8.5,6)
Shape 25
(9,5.5) , (8.5,5.5) , (8.5,5)
;;;;
run;
data line(keep=function drawspace x1 y1 x2 y2);
set TomTurkey;
by shapeID notsorted;
function='line';
drawspace='datavalue';
x1=lag(x);
y1=lag(y);
x2=x;
y2=y;
if ^first.shapeID;
run;
proc sgplot data=TomTurkey aspect=1 sganno=line;
scatter x=x y=y / markerattrs=(size=0);
run;
Thanks to Ted for the fun example!
Very cool. Just a reminder...SAS 9,4 SGPLOT also supports the POLYGON plot statement, so some of the vertex points from the original data set could have been used to directly drive a polygon plot.
Ok, but you only get a like if you post the code to make the sound to go with it though.
Turns out these are not polygons, but lines. Here is some fun with Series and Splines. Only the TomTurkey data set is needed.
/*--Line Turkey--*/
ods graphics / reset width=5in height=4in imagename='Turkey';
proc sgplot data=TomTurkey aspect=1 nowall noborder;
title 'Happy Turkey Day';
series x=x y=y / group=shapeid lineattrs=graphdata1(thickness=2);
xaxis display=none;
yaxis display=none;
run;
/*--Smooth Turkey--*/
ods graphics / reset width=5in height=4in imagename='TurkeySmooth';
proc sgplot data=TomTurkey aspect=1 nowall noborder;
title 'Happy Turkey Day';
series x=x y=y / group=shapeid lineattrs=graphdata1(thickness=2) smoothconnect;
xaxis display=none;
yaxis display=none;
run;
/*--Spline Turkey--*/
ods graphics / reset width=5in height=4in imagename='TurkeySpline';
proc sgplot data=TomTurkey aspect=1 nowall noborder;
title 'Happy Turkey Day';
spline x=x y=y / group=shapeid lineattrs=graphdata1(thickness=2);
xaxis display=none;
yaxis display=none;
run;
Spawned an interesting side discussion about CALL SOUND, moved to the off-topic lounge.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.