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

dad.png

 

Thanks to a little math help from StackExchange, here's a SAS ODS Graphics Happy Father's Day greeting!

 

* Fun w/SAS ODS Graphics: Happy Father's Day! (Scatter + Polygon + Text Plots)
  Star vertices algorithm from math.stackexchange.com/questions/3582342/coordinates-of-the-vertices-of-a-five-pointed-star;
  
data star;                                            * Generate points for stars;
retain id 0 r1 6 r2 2.5 dad "DAD" xT 0 yT 0;          * Star outer radius is 6, inner radius is 2.5;
pi=constant("pi");
do pt=1 to 600;                                       * Points for 600 little Unicode stars;
  xS=-6.25+12.5*ranuni(123); yS=-5.75+12.5*ranuni(456); output; 
end;
xS=.; yS=.;
do k=0 to 4;                                          * Points for 1 big polygon star;
  x=r1*cos(2*pi*k/5+pi/2); y=r1*sin(2*pi*k/5+pi/2); output; 
  x=r2*cos(2*pi*k/5+pi/2+2*pi/10); y=r2*sin(2*pi*k/5+pi/2+2*pi/10); output; 
end;

ods graphics / reset width=5in height=5in noborder;   * Make Dad a star!;      
proc sgplot noautolegend aspect=1 noborder nowall pad=0;          
styleattrs backcolor=navy;                             
symbolchar name=uniStar char='2605'x;                 * Unicode value for 5-pointed star;
scatter x=xS y=yS / markerattrs=(symbol=unistar color=White size=24pt); * Plot little unicode stars;
polygon x=x y=y id=id / fill fillattrs=(color=cxd9d9d9) dataskin=crisp; * Plot big polygon star;
text x=xT y=yT text=dad / contributeoffsets=none textattrs=(size=48pt color=navy weight=bold) contributeoffsets=none; * "DAD";
xaxis display=none values=(-6.25 6.25) offsetmin=.01 offsetmax=.01; * Hide axes; 
yaxis display=none values=(-5.75 6.75) offsetmin=.01 offsetmax=.01;             
run;
3 REPLIES 3
PaigeMiller
Diamond | Level 26

Searching documentation.sas.com for the text string unistar, it tells me "no items found". Where can we find out this symbol is available and other similar symbols as well?

--
Paige Miller
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

@PaigeMiller: SYMBOLCHAR is just a programmer-assigned name that will be associated with a Unicode character (see the SAS SGPLOT SYMBOLCHAR doc for the full story!). Here, I chose "unistar" as my name for the Unicode "Black Star" character, which I subsequently use to tell the SCATTER statement that the symbol represented by "unistar" is to be used as a marker for the plot (as opposed to a circle, square, diamond, etc.). Which Unicode characters you'll have access to depends on which fonts you have access to and in turn what Unicode support they provide. The free SAS OnDemand for Academics service includes the Arial Unicode MS font, which includes the Black Star character (x'2605') I used here. Check out this nice 2014 blog post by Lelia McConnell, which introduced the availability of SYMBOLCHAR for SGPLOT.

PaigeMiller
Diamond | Level 26

Thank you for the explanation! I was not aware of SYMBOLCHAR and I didn't know you could map a unicode symbol this way. Learn something new every day!

--
Paige Miller

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
  • 3 replies
  • 298 views
  • 8 likes
  • 2 in conversation