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

BeMine.png

* Generate x,y pairs to closely fit Valentine equation: (x**2+y**2-1)**3-x**2*y**3=0;

data pts;
do x=-2 to 2 by .001;
  do y=-2 to 2 by .001;
    delta=abs((x**2+y**2-1)**3-x**2*y**3);
    if delta<=.00015 then do;                   * Keep closest matches; 
     a=atan2(y,x);
     output;
     end;
   end;
 end;

* Sort in angle order for polygon plot;
 
 proc sort data=pts out=pts1;
 by a delta x;
 
 data pts2;
 set pts1;
 by a;
 if first.a;                                   * Keep closest match;
 id="BE*MINE";                                 * Message for heart;
 
proc sort data=pts2; 
by a;

* Plot polygon (not quite right, but flaws look like chipped candy!);
 
proc sgplot data=pts2 aspect=1;
polygon id=id x=x y=y / fill fillattrs=(color=pink) dataskin=matte splitchar='*' 
        label=id labelattrs=(size=50pt COLOR=lightred weight=bold);
run;

 

2 REPLIES 2
LauraRK
Quartz | Level 8

this is great!!  I will file it away!

tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

In response to my cry for help on SAS-L, Rick Wicklin suggested that if I didn't want to delve into the world of algebraic geometry just yet, I could probably obtain a better plot simply by finagling around the problematic x=0 and y=0 points, which indeed did the trick (thanks, Rick!).

 

Before and after images, together with the two lines of code that were tweaked to address the "crumbling" at the top and sides of the "before" Valentine:

 

CosmeticHeartSurgery.png

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch 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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 5993 views
  • 10 likes
  • 2 in conversation