I guess you want to cycle on the elements of your binary string, like this:
/* generate random binary heart similar to xkcd comic: http://xkcd.com/99/ */
data BinaryHeart;
drop Nx Ny t r i;
length B $1;
Nx = 21; Ny = 23;
*call streaminit(2142015);
i = 0;
str = "0110110101101111011011000110110001111001";
do x = -2.6 to 2.6 by 5.2/(Nx-1);
do y = -4.4 to 1.5 by 6/(Ny-1);
/* convert (x,y) to polar coordinates (r, t) */
r = sqrt( x**2 + y**2 );
t = atan2(y,x);
/* eqn: blogs.sas.com/content/iml/2011/02/14/a-parametric-view-of-love/ */
Heart= (r < 2 - 2*sin(t) + sin(t)*sqrt(abs(cos(t))) / (sin(t)+1.4))
& (y > -3.5);
*B = rand("Bernoulli", 0.5);
B = substr(str, 1+mod(i,length(str)), 1);
i + 1;
output;
end;
end;
run;
ods graphics / width=400px height=500px;
title "Happy Valentine's Day";
proc sgplot data=BinaryHeart noautolegend;
styleattrs datacontrastcolors=(lightgray red);
scatter x=x y=y / group=Heart markerchar=B markercharattrs=(size=10);
xaxis display=none offsetmin=0 offsetmax=0.06;
yaxis display=none;
run;
Playing with the length of the binary string will generate different patterns.
... View more