A quick SAS ODS Graphics take on a clever pony bead flag craft project. Have a great 4th, all!
* Fun With SAS ODS Graphics: Pony Bead 4th of July Flag Craft Project
Inspired by iheartcraftythings.com/pony-bead-flag-craft.html;
data flag; * Generate points for red/white/blue 'beads' & white stars;
do y=1 to 14; * 14 rows of beads;
do x=1 to 19; * 19 beads per row;
if y>=7 and x<=9 then color=1; * Blue beads for 'canton';
else if y in (1,2,5,6,9,10,13,14) then color=2; * Red beads for stripes;
else color=3; * White beads for stripes;
output;
end;
end;
x=.;y=.;
do y2=7.75 to 13.5 by (13.5-7.75)/3; * 4 rows of stars, distribute evenly;
do x2=1.75 to 8.25 by (8.25-1.75)/3; * 4 columns of stars, distribute evenly;
output;
end;
end;
* Make a flag using ellipse and scatter plots;
ods graphics / antialias height=7in width=9.5in imagefmt=svg noborder; * Make height/width proportional to rows/columns;
proc sgplot data=flag noborder noautolegend pad=0 nowall;
styleattrs backcolor=cx3C3B6E datacolors=(red white blue); * Navy-ish blue background;
symbolchar name=uniStar char='2605'x; * Unicode value for 5-point star;
ellipseparm semimajor=.48 semiminor=.48 / fill xorigin=x yorigin=y group=color nomissinggroup; * Red/white/blue 'beads';
scatter x=x y=y / markerattrs=(color=cx3C3B6E symbol=circlefilled size=15pt); * 'Holes' in center of 'beads';
scatter x=x2 y=y2 / markerattrs=(symbol=uniStar color=white size=96pt); * White stars;
xaxis display=none values=(.5 to 19.5) offsetmin=0 offsetmax=0; * Suppress axes and minimize padding around markers;
yaxis display=none values=(.5 to 14.5) offsetmin=0 offsetmax=0;
run;
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.