Here's a SAS ODS Graphics (GTL) take on those Turkey headband craft projects for kids. Happy Thanksgiving, all!
* Fun With SAS ODS Graphics: Thanksgiving Turkey Crown
Inspired by turkey headband craft for kids at etsy.com/listing/1077344850/thanksgiving-turkey-paper-crown-kids;
data feathers; * Generate angles, x/y points for 7 feathers;
r=535;
retain fxo 711.5 fyo 615; * Triangles originate at x=711.5, y=615;
do aDeg=180 to 360 by 180/7; * aDeg is angle in degrees;
aRad=2*constant("pi")*(aDeg/360); * aRad is angle in radians;
fx=r*cos(aRad)+711.5; * Compute x,y coordinates;
fy=r*sin(aRad)+615;
c+1; * Assign 1 of 4 colors (will cycle thru them);
color=mod(c-1,4);
output;
end;
* Generate polygon points for feathers (triangles);
data featherspolygons(keep=polyfid polyfx polyfy color);
set feathers;
retain pfx pfy;
if _n_>1 then do;
polyfid+1; polyfx=pfx; polyfy=pfy; output; polyfx=fx; polyfy=fy; output; polyfx=711.5; polyfy=615; output; end;
pfx=fx; pfy=fy;
* Generate points, lengths, slopes for ellipses to gently round ends of triangular feathers;
data feathersellipses(keep=ellipsefid ellipsefx ellipsefy ellipseslope major minor color);
set feathers;
retain pfx pfy;
if _n_>1 then do;
ellipseslope=(fy-pfy)/(fx-pfx); ellipsefid+1; ellipsefx=(fx+pfx)/2; ellipsefy=(fy+pfy)/2; major=sqrt((fy-pfy)**2+(fx-pfx)**2)/2; minor=60; output; end;
pfx=fx; pfy=fy;
data polybeak; * Generate polygon points for beak (triangle);
polybid=1; polybx=641; polyby=660; output; polybx=782; output; polybx=711.5; polyby=750; output;
data polyheadband; * Generate polygon points for headband (rectangle);
id=1;
px=711.5-591.5; py=600; output; px=711.5+591.5; output; py=810; output; px=711.5-591.5; output;
data turkeyparts; * Merge all the parts together;
set featherspolygons feathersellipses polybeak polyheadband;
proc template; * Use GTL to plot parts of the turkey (above polygons/ellipses + new parts specfied below);
define statgraph turkey;
begingraph / border=false backgroundcolor=silver datacolors=(cx704204 red orange yellow sienna red orange yellow sienna red); * Thanksgiving-themed colors;
layout overlayequated / border=false backgroundcolor=silver wallcolor=silver WALLDISPLAY=(FILL)
xaxisopts=(display=none thresholdmin=0 thresholdmax=0) yaxisopts=(display=none reverse=true); * Reverse y-axis, since x/y points came from MS-Paintbrush (where y=0 is at top instead of bottom);
polygonplot x=px y=py id=id / display=(fill) fillattrs=(color=brown); * Headband;
ellipseparm semimajor=591.5 semiminor=120 slope=0 xorigin=711.5 yorigin=600 / display=(fill) fillattrs=(color=lightgrey); * Headband top/inside;
polygonplot x=polyfx y=polyfy id=polyfid / display=(fill) group=color; * Feathers;
ellipseparm semimajor=352 semiminor=245 slope=0 xorigin=711.5 yorigin=615 / display=(fill) fillattrs=(color=brown); * Head;
ellipseparm semimajor=30 semiminor=30 slope=0 xorigin=558 yorigin=592 / display=(fill) fillattrs=(color=black); * Left eye;
ellipseparm semimajor=30 semiminor=30 slope=0 xorigin=865 yorigin=592 / display=(fill) fillattrs=(color=black); * Right eye;
ellipseparm semimajor=591.5 semiminor=120 slope=0 xorigin=711.5 yorigin=810 / display=(fill) fillattrs=(color=brown); * Bottom of headband;
ellipseparm semimajor=40 semiminor=90 slope=0 xorigin=711.5 yorigin=790 / display=(fill) fillattrs=(color=redorange); * Turkey's 'snood';
polygonplot x=polybx y=polyby id=polybid / display=(fill outline) fillattrs=(color=yellow) outlineattrs=(color=redorange thickness=4pt); * Outlined beak;
ellipseparm semimajor=major semiminor=minor slope=ellipseslope xorigin=ellipsefx yorigin=ellipsefy / group=color display=(fill); * Rounded tips of feathers;
endlayout;
entryfootnote textattrs=(size=24pt weight=bold color=black) "HAPPY THANKSGIVING!"; * Greetings!;
endgraph;
end;
run;
proc sgrender data=turkeyparts template=turkey; * Generate chart!;
run;
ROUGH DRAFT
/*===========================================
1. Create gratitude words with weights
===========================================*/
data gratitude_words;
length word $20;
input word $ size_weight;
datalines;
Family 28
Health 26
Friends 30
Hope 22
Kindness 25
Nature 20
Learning 24
Laughter 22
Community 21
Sunshine 19
Comfort 20
Peace 23
Patience 18
Gratitude 32
;
run;
/*===========================================
2. Assign random XY positions for scatter plot
===========================================*/
data wordcloud;
set gratitude_words;
/* random positions in a 0–100 space */
x = rand("uniform") * 100;
y = rand("uniform") * 100;
/* Convert weight to approximate text size */
text_size = size_weight;
/* Random pastel colors */
array colors[5] _temporary_ (1 2 3 4 5);
color = colors[ceil(rand("uniform")*5)];
run;
/*===========================================
3. Plot the word cloud
===========================================*/
ods graphics / reset width=10in height=8in noborder;
proc sgplot data=wordcloud noautolegend;
/* Word cloud using TEXT plot */
text x=x y=y text=word /
textattrs=(weight=bold)
sizeresponse=text_size sizemin=8 sizemax=32
colormodel=(blue red violet green orange)
COLORRESPONSE=color
;
xaxis display=none;
yaxis display=none;
title height=20pt "Gratitude Word Cloud";
run;This post uses a scatter plot with custom markers to display a statistic about the percentage of Americans eating turkey for Thanksgiving.
This post uses a scatter plot with custom markers to display a statistic about the percentage of Americans eating turkey for Thanksgiving.
proc sgplot data=sashelp.class; highlow x=name low=0 high=height / type=bar fillattrs=(color=steelblue); run;
proc template;
define statgraph turkey;
begingraph / border=false backgroundcolor=#f4f2e9
datacolors=(#8B4513 #CC5500 #E3963E #FFD97D #7A5230
#CC5500 #E3963E #FFD97D #7A5230);
layout overlayequated / border=false
backgroundcolor=#f4f2e9 wallcolor=#f4f2e9
WALLDISPLAY=(FILL)
xaxisopts=(display=none thresholdmin=0 thresholdmax=0)
yaxisopts=(display=none reverse=true);
polygonplot x=px y=py id=id / display=(fill)
fillattrs=(color=#7A5230); /* Headband */
ellipseparm semimajor=591.5 semiminor=120 slope=0
xorigin=711.5 yorigin=600 / display=(fill)
fillattrs=(color=#d9d5cc); /* Headband inner */
polygonplot x=polyfx y=polyfy id=polyfid / display=(fill) group=color;
ellipseparm semimajor=352 semiminor=245 slope=0
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.