BookmarkSubscribeRSS Feed
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

PopsicleStickFlag.png

 

I did my share of popsicle stick craft projects as a kid, including "switch blades" and "bombs." 😀

 

So, with Independence Day approaching, here's a quick SAS ODS Graphics take on a Popsicle Stick American Flag craft project. Happy 4th of July, all!

 

* Fun With SAS ODS Graphics: Stars and Popsicle Stick Stripes Forever
  See craft projoect at: gingersnapcrafts.com/blast-from-past-popsicle-stick-flags;
  
data stripes;                        * Generate rectangles for 5 popsicle stick stripes;
do id=1 to 5;
  color=mod(id,2);                   * Assign color codes 0=Red 1=White 2=Blue;   
  x=.33; y=(id-1)*.72; output; x=6-.33; output; y=(id-1)*.72+.66; output; x=.33; output;
end;

data canton;                          * Generate 3 shorter blue rectangles for canton;
do id=3 to 5;
  csx=.33; csy=(id-1)*.72; output; csx=3; output; csy=(id-1)*.72+.66; output; csx=.33; output;
end;

data circles(keep=colorc xc yc);     * Generate circles for rounded ends of popsicle stick stripes;
do id=1 to 5; 
  if id<=2 then colorc=mod(id,2); else colorc=2; 
  xc=.33; yc=(id-1)*.72+.33; output; colorc=mod(id,2); xc=6-.33; output; 
end;

data stars(keep=xs ys);               * Generate 3 rows of stars (5 in each row); 
do id=3 to 5; 
  ys=(id-1)*.72+.37; 
  do s=1 to 5; xs=s*3/6; output; end; 
end;

data flag;                            * Pull all the pieces together;
set stripes circles canton stars; 
                                      * Make a flag with polygon + ellipseparm + scatter plots!; 
ods graphics / noborder height=3.54in width=6in;
proc sgplot data=flag noautolegend nowall noborder;
styleattrs backcolor=cxb1e5ff datacolors=(CXB22234 white CX3C3B6E);     * "Old Glory Red/Blue";
symbolchar name=uniStar char='2605'x; * Unicode value for 5-pointed star;
polygon x=x y=y id=id / nooutline fill colormodel=(white CXB22234) colorresponse=color nomissinggroup; * Plot rectangular part of stripes; 
ellipseparm semimajor=.33 semiminor=.33 / slope=1 xorigin=xc yorigin=yc fill nooutline group=colorc nomissinggroup; * Plot rounded ends of stripes;
polygon x=csx y=csy id=id / nooutline fill fillattrs=(color=CX3C3B6E);  * Plot canton; 
scatter x=xS y=yS / markerattrs=(symbol=unistar color=White size=48pt); * Plot stars;
xaxis display=none values=(0 6) offsetmin=.06 offsetmax=.06;            * Hide axes; 
yaxis display=none values=(0 3.6) offsetmin=.0625 offsetmax=.06;             
run;

  

PRE-COLORING

PopsicleStickFlagBW.png

1 REPLY 1
GraphGuy
Meteorite | Level 14

@tc  never disappoints!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 228 views
  • 7 likes
  • 2 in conversation