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

mothersday.png

 

A bit late in the day, but Happy Mother's Day, all!

 

* Fun With SAS ODS Graphics: Mother and Child (Polygon+Ellipse+Vector Plots)
  Points courtesy of Fahmihorizon from Mother icon (thenounproject.com/icon/mother-1477298)
  X/Y coordinates obtained via the nifty PlotDigitizer app (plotdigitizer.com); 

data mom;                                 * Generate required points;  
input x y desc $30.;
select (desc);
  when ('Mom - Head - Center') do; mhcx=x; mhcy=y; input mhrx mhry desc $30.; mhr=mhrx-mhcx; output; end; 
  when ('Mom - Body') do; mbx=x; mby=y; polygon=1; group=1; output; end;
  when ('Carriage Top - Center') do; ctcx=x; ctcy=y; input ctlx ctly desc $30.; ctr=ctcx-ctlx; output; retain ctcx; end; 
  when ('Carriage Bottom - Top Center') do;   * Note: Carriage is an ellipse masked with a polygon and bisected with a line; 
    cbtcx=x; cbtcy=y; input cbbcx cbbcy desc $30.; input cbtrx cbtry desc $30.; cbr2=cbtrx-cbbcx; cbr1=cbtcy-cbbcy; output;   
    polygonM=1; groupM=1; xM=ctcx; yM=cbtcy; output; yM+(cbtrx-cbbcx)+.01; output; xM=cbtcx+(cbtcy-cbbcy)+.01; output; yM=cbtcy; 
    vx=xM+.01; vy=yM; vxo=cbtcx-(cbtcy-cbbcy)-.01; vyo=yM; output; end;
  when ('Left Wheel - Center') do; lwcx=x; lwcy=y; input lwtx lwty desc $30.; lwr=lwty-lwcy; output; end; 
  when ('Right Wheel - Center') do; rwcx=x; rwcy=y; input rwtx rwty desc $30.; rwr=rwty-rwcy; output; end;
  when ('Handle') do; hx=x; hy=y+.01; input hxo hyo desc $30.; hyo+(-.01); output; end;
end;                                      * Digitized points obtained via PlotDigitizer app (plotdigitizer.com); 
datalines;    
0.544594595 0.75261324  Mom - Body
0.468918919 0.534843206 Mom - Body
0.501351351 0.515679443 Mom - Body
0.559459459 0.681184669 Mom - Body
0.513513514 0.402439024 Mom - Body
0.555405405 0.400696864 Mom - Body
0.555405405 0.158536585 Mom - Body
0.595945946 0.156794425 Mom - Body
0.601351351 0.400696864 Mom - Body
0.612162162 0.400696864 Mom - Body
0.62027027  0.156794425 Mom - Body
0.659459459 0.156794425 Mom - Body
0.659459459 0.400696864 Mom - Body
0.705405405 0.400696864 Mom - Body
0.656756757 0.679442509 Mom - Body
0.709459459 0.520905923 Mom - Body
0.745945946 0.534843206 Mom - Body
0.67027027  0.75261324  Mom - Body
0.608108108 0.834494774 Mom - Head - Center
0.660810811 0.834494774 Mom - Head - Right
0.241891892 0.168989547 Left Wheel - Center
0.241891892 0.205574913 Left Wheel - Top
0.440540541 0.170731707 Right Wheel - Center
0.440540541 0.203832753 Right Wheel - Top
0.328378378 0.350174216 Carriage Top - Center
0.2         0.350174216 Carriage Top - Left
0.337837838 0.339721254 Carriage Bottom - Top Center
0.337837838 0.177700348 Carriage Bottom - Bottom Center
0.483783784 0.337979094 Carriage Bottom - Top Right
0.483783784 0.524390244 Handle
0.47027027  0.339721254 Handle
;                                       * Generate chart of mother/child (Polygon+Ellipse+Vector plots);     
ods graphics / reset height=5.7in width=7.3in;;
proc sgplot data=mom aspect=1 noborder nowall noautolegend;
styleattrs backcolor=cxf10427; 
ellipseparm semimajor=mhr semiminor=mhr / xorigin=mhcx yorigin=mhcy fill fillattrs=(color=white);       * Head;
polygon x=mbx y=mby id=polygon / fill fillattrs=(color=white) group=group nomissinggroup;               * Body; 
ellipseparm semimajor=lwr semiminor=lwr / xorigin=lwcx yorigin=lwcy fill fillattrs=(color=white);       * Left carriage wheel;
ellipseparm semimajor=rwr semiminor=rwr / xorigin=rwcx yorigin=rwcy fill fillattrs=(color=white);       * Right carriage wheel;
ellipseparm semimajor=cbr1 semiminor=cbr2 / xorigin=cbtcx yorigin=cbtcy fill fillattrs=(color=white);   * Baby carriage;
polygon x=xM y=yM id=polygonM / fill fillattrs=(color=cxf10427) group=groupM nomissinggroup;            * Mask top right of ellipse to create sunscreen cover;
vector x=vx y=vy / xorigin=vxo yorigin=vyo noarrowheads lineattrs=(color=cxf10427 thickness=3pt);       * Bisect ellipese with a line;
vector x=hx y=hy / xorigin=hxo yorigin=hyo noarrowheads lineattrs=(color=white thickness=5pt);          * Carriage handle;
xaxis display=none min=-.05 max=.95 offsetmax=.001 offsetmin=.001;                                      * Limit x/y axis bounds;
yaxis display=none min=0 max=1 offsetmax=.001 offsetmin=.001;
inset "HAPPY MOTHER'S DAY!" / position=bottom textattrs=(size=14pt weight=bold color=white);            * Message at bottom;
run;

 

Grabbing x/y points with Plot DigitizerGrabbing x/y points with Plot Digitizer

 

Chart-in-Progress Pre-Fill "Wireframe"Chart-in-Progress Pre-Fill "Wireframe"

1 REPLY 1
SASKiwi
PROC Star

Wow! This takes me way back to when I actually used a physical plotter holding a sight pen which contained a lens plus cross-hairs to physically digitize a picture. Nice to know you can do it all virtually now!

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 565 views
  • 4 likes
  • 2 in conversation