## Give A Geeky Valentine!

Community Manager
Posts: 634

# Give A Geeky Valentine!

Just in time for Valentine's Day, delivers code to create a binary message of love for that special someone. Read his blog,

borrow the code and share the love!

-
Bev Brown
Posts: 1,305

## Re: Give A Geeky Valentine!

Your hyperlink for the blog post is missing the semicolon after http

http://blogs.sas.com/content/iml/2015/02/11/binary-heart/

Community Manager
Posts: 634

## Re: Give A Geeky Valentine!

Thank you! Fixed now.

-
Bev Brown
Posts: 1,305

## Re: Give A Geeky Valentine!

proc fcmp outlib=work.funcs.graph;

function heartx(t);

return(16*sin(t)**3);

endsub;

function hearty(t);

return(13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t));

endsub;

run;

options cmplib=work.funcs;

proc template;

define statgraph heart;

dynamic T;

begingraph;

entrytitle " ";

entryfootnote "{16*sin(t)^3, 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t)}, {t, 0, 2*pi}";

layout overlay / yaxisopts=(

label=" "

display=none

)

xaxisopts=(

label=" "

display=none

)

;

entry "Happy Valentines Day";

if (exists(T))

seriesplot x=eval(heartx(T)) y=eval(hearty(T));

endif;

endlayout;

endgraph;

end;

run;

data foo;

drop pi;

pi = constant('pi');

do t=0 to 2*pi by 0.01*pi/4;

output;

end;

run;

proc sgrender data=foo template=heart;

dynamic t="T";

run;

Community Manager
Posts: 634

:smileylove:

-
Bev Brown
Posts: 1,305

## Re: Give A Geeky Valentine!

How about one or two more...  I don't often need to build graphs, so this has been a fun exercise.

proc fcmp outlib = work.funcs.graphs;

function heart3d(x,y);

t = 1 - x**2 - (y - abs(x))**2;

if sign(t)=-1 then return(0);

return(5-sqrt(t)*cos(30*t));

endsub;

run;

options cmplib=work.funcs;

proc template;

define statgraph heart3d;

dynamic X Y;

begingraph;

layout lattice / rows=1 columns=2;

layout overlay3d / cube=false rotate=5 tilt=85;

surfaceplotparm x=X y=Y z=eval(heart3d(X,Y)) /

surfacetype = fillgrid;

endlayout;

layout overlay;

contourplotparm x=X y=Y z=eval(heart3d(X,Y)) /

contourtype = fill;

endlayout;

endlayout;

endgraph;

end;

run;

data ranges / view=ranges;

do x=-1 to 1 by .01;

do y=-1 to 1.5 by .01;

output;

end;

end;

run;

proc sgrender data=ranges template=heart3d;

dynamic x="x" y="y";

run;

Community Manager
Posts: 634

## Re: Give A Geeky Valentine!

These are great! Goes to show...SAS has a heart

-
Bev Brown
Posts: 1,365

## Re: Give A Geeky Valentine!

Including the SAS/Graph guy, Robert Allison's geeky contribution... http://blogs.sas.com/content/sastraining/2015/02/12/have-a-traditional-sasgraph-valentines-day/

Community Manager
Posts: 634

## Re: Give A Geeky Valentine!

Did you know Cupid himself uses SAS? Me either. He's more entrepreneurial than I expected: http://blogs.sas.com/content/sascom/2015/02/11/you-know-what-cupid-loves-money-lots-of-money/

-
Bev Brown