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

SAS ODS Graphics KnockoffSAS ODS Graphics KnockoffDIY Xmas Tree CardDIY Xmas Tree Card

Here's a quick X-ACTO knife-free SAS ODS Graphics take on a neat Xmas craft project (Steph Curry ornaments sold separately). Happy Holidays!

 

* Fun w/SAS ODS Graphics: "3-Pointer" Xmas Tree
  Inspired by craft project at https://howaboutorange.blogspot.com/2012/12/diy-geometric-christmas-tree-card.html;
  
data tree;
w=.9;                          * Length of sides of equilateral triangles (leave 10% white space);
h=.9*sqrt(3)/2;                * Height of equilateral triangles (length of sides * sqrt(3)/2);
do r=0 to -5 by -1;            * 6 rows;
  do c=r/2 to r/2+abs(r);      * 1-6 triangles per row;
    up=1;                      * 3 polygon points for triangles pointing up (dark green);
    id+1;                      * Polygon identifier;
    x=c; y=r+.5*h; output;     * Point at triangle top;  
    x=c-w/2; y=r-h/2; output;  * Point at base (left);
    x=c+w/2; y=r-h/2; output;  * Point at base (right);
    up=0;                      * 3 polygon points for triangles pointing down (light green);
    id+1;                      * Polygon identifier;
    x=c; y=r-1.5*h; output;    * Point at trianngle top; 
    x=c-w/2; y=r-h/2; output;  * Point at base (left);
    x=c+w/2; y=r-h/2; output;  * Point at base (right);
  end;
end;
                               * Plot the "tree" of triangles (polygon plot);
ods graphics / reset antialias width=5in height=5in;                               
proc sgplot data=tree noautolegend aspect=1 subpixel noborder;
polygon x=x y=y id=id / colormodel=(cx00FF3E cx00B32C) colorresponse=up fill;
xaxis display=none offsetmin=.05 offsetmax=.05; 
yaxis display=none offsetmin=.05 offsetmax=.05;
1 REPLY 1
Ksharp
Super User

How about this one ?

 

data have;
group=1;
 do x=1 to 11 by 2;
  y=1;output;
 end;
 do x=2 to 10 by 2;
  y=3;output;
 end;
 do x=3 to 9 by 2;
  y=5;output;
 end;
 do x=4 to 8 by 2;
  y=7;output;
 end;
 do x=5 to 7 by 2;
  y=9;output;
 end;
 x=6;y=11;output;
 
 group=2;
 do x=1 to 11 by 2;
  y=2;output;
 end;
 do x=2 to 10 by 2;
  y=4;output;
 end;
 do x=3 to 9 by 2;
  y=6;output;
 end;
 do x=4 to 8 by 2;
  y=8;output;
 end;
 do x=5 to 7 by 2;
  y=10;output;
 end;
 x=6;y=12;output;
run;
data have;
 set have;
 if group=1 then y=y-0.38;
 if group=2 then y=y+0.38;
run;
 
ods graphics / attrpriority=none  ;
proc sgplot data=have noautolegend noborder aspect=1;
styleattrs datasymbols=(triangledownfilled trianglefilled)  
datacontrastcolors=(cx00FF3E cx00B32C);
scatter x=x y=y /group=group markerattrs=( size=50) ;
xaxis display=none;
yaxis display=none;
run;

x.png

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1101 views
  • 4 likes
  • 2 in conversation