BookmarkSubscribeRSS Feed
michael_friendly
Fluorite | Level 6

[Running SAS 9.2 on linux]

This may be more a SAS/Graph question, but occurs in an IML context...

A cc:'d reply to friendly@yorku.ca would be appreciated, if this doesn't violate protocol for this discussion.

In the code below, I am plotting two overlapping circles using gpie and wish to draw attention to the area of overlap.

Rather than using cross-hatch patterns, I would prefer solid fill using transparent colors.  I tried appending

an alpha value to the hex codes for red and blue, e.g., CXrrggbbaa, but that doesn't have an effect.

Does SAS 9.2 support transparent colors in some other way?

proc iml;

start twocirc(cx, cy, radius, r, labels, colors, patterns);

   *-- Draw two circles showing partial relations;

   rsq = r##2;

   d = centdist( rsq ) # radius;

   x  = (cx - d/2)//

        (cx + d/2);

   y  = cy // cy;

   print 'Circle centers', x y radius rsq;

   call gpie(x, y, radius, 0, 360, colors, , patterns);

   call gpiexy(lx1, ly1, 1.25, 240, x[1]||y[1], radius);

   call gpiexy(lx2, ly2, 1.25, 300, x[2]||y[2], radius);

   call gstrlen(len,labels);

   lx = lx1-len[1] // lx2;

   ly = ly1 // ly2;

   call gscript(lx, ly, labels);

finish;

start centdist( r );

   *-- Compute distance between centers of circles from rsq;

   if r = 1 then return( 0 );         /* complete overlap     */

   else if r = 0 then return( 2 );    /* completely disjoint  */

   else do;                           /* intersecting circles */

      pi = 3.14159;

      lo = 0;  hi = pi;     /* angle theta, 0 <= theta <= pi radians */

      q = r # pi;           /* sector area of overlap */

      old = 0;

      alpha = pi/2;

      delta = 1;

      iter=0;

      do until (delta < .001);

         iter = iter + 1;

         if iter > 20 then goto done;

         z = alpha - sin(alpha);

         if z = q then delta = 0;

         else do;          /* adjust */

            old = alpha;

            if z > q then do;

               alpha = alpha - (alpha-lo)/2;

               hi = old;

            end;

            else do;

               alpha = alpha + (hi-alpha)/2;

               lo = old;

            end;

            delta = abs(old-alpha);

         end;

      end;

done:

*  print iter alpha delta lo hi;

   alpha = alpha/2;

   dist = 2 # cos(alpha);

   end;

   return( dist );

finish;

   call gstart;

   call gwindow({-5 -5 , 104 104});

   colors = { 'CXFF00000080', 'CX0000FF80' };

   patterns = {'psolid', 'psolid'};

   cx = 50; cy=50;

   rad = 25;

   r = .60;

   lab = {'Y.X' 'X.Y'};

   run twocirc(cx, cy, rad, r, lab, colors, patterns);

   call gshow;

1 REPLY 1
Rick_SAS
SAS Super FREQ

As far as I know, the old G-style graphics in PROC IML do not support transparency.

If you have SAS 9.22 or later, you can use the SUBMIT/ENDSUBMIT statements in the twocirc module.

I think I'd try to solve this problem by using a SUBMIT statement  to call a SAS/GRAPH or ODS Graphics procedure that supports transparency.

SAS Innovate 2025: Register Now

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!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 1026 views
  • 0 likes
  • 2 in conversation