Have a great 4th of July weekend, all!
* Fun w/SAS ODS Graphics, 4th of July Stars-and-Stripes BBQ Grill;
data stars(keep=x y); /* Generate x/y points for white stars on blue background */
do y=-1.25 to 1.25 by .1; do x=-1.25 to 1.25 by .1; output; end; end;
data top(keep=tp tx ty); /* Generate x/y points for top half of grill (blue) */
tp=1; /* Polygon semi-circle points */
tx=-.95; ty=sqrt(1-tx**2); output; /* Starting point - only .95 wide instead of 1 to leave room for text */
do tx=-.95 to .95 by .01; ty=sqrt(1-tx**2); output; end; /* points of semicircle */
tx=.95; ty=sqrt(1-tx**2); output; /* End point */
tx=-.95; ty=sqrt(1-tx**2); output; /* Starting point - only .95 wide instead of 1 to leave room for text */
proc sql; /* x/y points for bottom of grill (red) same as top, just negate y */
create table bottom as select tp as bp, tx as bx, -ty as by from top order by 2;
update top set ty=ty+.2; /* Adjust y-position of top/bottom up for text & legs */
update bottom set by=by+.5;
data stripes(keep=sp sx sy); /* Generate x/y points for white stripes on red background */
sp=1; do y=.5 to -1.5 by -.2; sx=-1.2; sy=y; output; sx=1.2; output; sy+(-.1); output; sx=-1.2; output; end;
data text; /* Text to display in middle of grill */
txtx=0; txty=.35; txt="HAPPY 4TH OF JULY!";
data legs(keep=lx1 ly1 lx2 ly2); /* Generate pairs of x/y points for grill legs (red) */
lx1=-.3; ly1=-.425; lx2=-.7; ly2=-1.35; output; /* Left leg */
lx1=.3; ly1=-.425; lx2=.7; ly2=-1.35; output; /* Right leg */
data grillpoints; /* Merge all the points together */
set stars top bottom stripes text legs;
/* Let's plot a grill! (Polygon+Scatter+Series+Text+Vector Plots) */
ods graphics / antialias border height=5in width=5in;
proc sgplot data=grillpoints noautolegend noborder pad=0 nowall subpixel;
symbolchar name=uniStar char='2605'x; /* Unicode value for 5-pointed star */
inset "(*ESC*){unicode '03c0'x}" / noborder position=top textattrs=(size=30pt weight=bold color=CX3C3B6E); /* Use unicode PI symbol for "handle" */
polygon x=tx y=ty id=tp / fill lineattrs=(color=CX3C3B6E) fillattrs=(color=CX3C3B6E); /* Top of grill filled (blue) */
scatter x=x y=y / markerattrs=(symbol=unistar color=CXFFFFFF size=22pt); /* Stars (white) */
series x=tx y=ty / lineattrs=(color=CX3C3B6E thickness=2pt); /* Top of grill outline (blue) */
polygon x=bx y=by id=bp / fill lineattrs=(color=CXB22234) fillattrs=(color=CXB22234); /* Bottom of grill filled (red) */
polygon x=sx y=sy id=sp / fill lineattrs=(color=white) fillattrs=(color=white); /* Stripes (white) */
series x=bx y=by / lineattrs=(color=CXB22234 thickness=2pt); /* Bottom of grill outline (red) */
text x=txtx y=txty text=txt / textattrs=(size=19pt weight=bold color=black); /* Happy 4th of July! text (black) */
vector x=lx1 y=ly1 / xorigin=lx2 yorigin=ly2 noarrowheads lineattrs=(color=CXB22234 thickness=9pt); /* Grill legs (red) */
xaxis display=none offsetmin=.1 offsetmax=.1 values=(-1.2 1.2); /* Suppress axes display */
yaxis display=none offsetmin=.1 offsetmax=.1 values=(-1.2 1.2);
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.