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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.