## Create fun Halloween pics with math -- and SAS University Edition!

Community Manager
Posts: 3,432

# Create fun Halloween pics with math -- and SAS University Edition!

[ Edited ]

SAS Graph Genius @RobertAllison_SAS has made SAS graphing a little bit less scary this Halloween.  In this blog post, he shared the graphing techniques that you can use to create any shape that you want using SAS.

Robert's techniques make use of SAS/GRAPH procedures, which are part of a specialized graphing package in SAS.  The trick: the SAS/GRAPH package is not part of SAS University Edition. But here's the treat: you do have access to PROC SGPLOT, which is part of the Base SAS package.  With a hint from @Rick_SAS in the comments, we can adapt Robert's code to use PROC SGPLOT and the POLYGON statement.

Here's a modified version of the code that runs perfectly in SAS University Edition:

``````/*
Inspiration from Robert Allison and Rick Wicklin @ SAS
Using coordinates from:
*/
data bat_data;
id='bat';
input x y;
datalines;
7 6
8 5
9.5 4
11 3.5
13 3
10.5 2.5
8.5 1.5
7.5 .5
5 .5
3.5 0
2.5 -1
2 -2
1 -1.5
-1 -1
-2.5 -1.5
-4 -2.5
-5 0
-7 1.5
-9 1.5
-8.5 4
-9.5 5.5
-12 6
-13 9
-14 10.5
-11 10.5
-9 10.5
-8 11
-7 8
-5.5 5.5
-4 4
-2.5 6
-2.5 5
-1.5 5
-.5 4.5
0 5
-.5 3
0 2.5
1 3
3 4
5 5
. .
-3 4
-2.5 4.5
-2.5 3.5
. .
-2 3.5
-1 4
-1 3.5
;
run;

data cat_data;
id='cat';
input x y;
datalines;
0 0
1 -1.5
1.5 -3
2 -5
2 -6
1.5 -7
3 -7.5
4 -7.5
5.5 -7
5 -6.5
3 -6
3 -5
4 -2.5
5 -1
6 0
7 1
8.5 2
10 2.5
11 3
10 3.5
9 4.5
9.5 6.5
8 5
6 5
5 5.5
4 7
3.5 4
2.5 3.5
4 2
3 1.5
2 2.5
1.5 4
1 6
0 7
-2 7.5
-4 7
-5 6.5
-6 5
-7 4
-7.5 3.5
-8.5 4
-8.5 9
-9.5 10
-11 10.5
-13 10
-14 9
-13.5 8
-13 7.5
-11.5 8
-10 4.5
-9 2
-8 0
-7 -2.5
-6.5 -5
-5.5 -6
-4.5 -7.5
-1.5 -7.5
-1.5 -6.5
-2.5 -6
-4 -6.5
-5 -5
-5 -3
-4.5 -1
-3 .5
-1 .5
. .
6 3
6.5 3
6 4
4.5 4.5
5 3.5
. .
7 3
8.5 3
9 3.5
8 4
;
run;

data witch_data;
id='witch';
input x y;
datalines;
-1 11
1 8
2 6
1.5 5.5
2 5
2.5 5.5
3 5
2.5 4.5
1 4.5
0 4
-1 3
-2 1
-3 -1
-3 -2
-2.5 -2.5
-1 -2
-1 -2.5
-2 -3
-4 -3.5
-4.5 -3.5
-5 -3
-6.5 -4
-13 -3
-13.5 -5
-13 -7
-12 -8.5
-10 -7
-7 -5
-6 -4.5
-4.5 -5
-4.5 -4.5
-3.5 -4
-1.5 -3.5
-1 -4.5
-1.5 -5
-2 -5
-2.5 -4.5
-3.5 -4.5
-4.5 -6
-5.5 -8
-4 -7
-2 -6
2 -5.5
4 -4.5
4.5 -4
4 -3.5
3.5 -2.5
7 -2
13 -.5
13 .5
11 0
9 -.5
6 -.5
4 0
3.5 1
3.5 3
5 3
4.5 4
5.5 3.5
6 4.5
7 5
6.5 5.5
5.5 6
5 7
5.5 7.5
5.5 8
5 7.5
4.5 7.5
4 8
2 9
. .
2.5 -.5
4 -1.5
2.5 -2
;
run;

proc sgplot data=bat_data;
polygon x=x y=y id=id / outline lineattrs=(color=red) fill
fillattrs=(color=gray44);
xaxis display=none;
yaxis display=none;
run;

proc sgplot data=cat_data;
polygon x=x y=y id=id / outline lineattrs=(color=red) fill
fillattrs=(color=gray44);
xaxis display=none;
yaxis display=none;
run;

proc sgplot data=witch_data;
polygon x=x y=y id=id / outline lineattrs=(color=red) fill
fillattrs=(color=gray44);
xaxis display=none;
yaxis display=none;
run;``````

Want to create your own shapes? You can use this Graphing Worksheets site to help develop the coordinates.  And see how to use PROC SGPLOT with more shapes in this blog post from @MarciaS.

Discussion stats
• 0 replies
• 797 views
• 2 likes
• 1 in conversation