<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using markerchar to plot a repeated string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-markerchar-to-plot-a-repeated-string/m-p/491731#M129033</link>
    <description>&lt;P&gt;I'm trying to use the following code to replicate XKCD's Binary Heart comic:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* generate random binary heart similar to xkcd comic: http://xkcd.com/99/ */
data BinaryHeart;
drop Nx Ny t r;
Nx = 21; Ny = 23;
call streaminit(2142015);
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 &amp;lt; 2 - 2*sin(t) + sin(t)*sqrt(abs(cos(t))) / (sin(t)+1.4)) 
&amp;amp; (y &amp;gt; -3.5);
B = rand("Bernoulli", 0.5);
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;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd love to swap out the random binary for a specific binary string, but can't quite figure out the spacing. When I use the following, all the numbers overlap, but when I try to add spacing I get an error that SAS was expecting an arithmetic operator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* generate random binary heart similar to xkcd comic: http://xkcd.com/99/ */
data BinaryHeart;
drop Nx Ny t r;
Nx = 21; Ny = 23;
call streaminit(2142015);
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 &amp;lt; 2 - 2*sin(t) + sin(t)*sqrt(abs(cos(t))) / (sin(t)+1.4)) 
&amp;amp; (y &amp;gt; -3.5);
B=(0110110101101111011011000110110001111001);
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;&lt;/PRE&gt;</description>
    <pubDate>Fri, 31 Aug 2018 19:49:17 GMT</pubDate>
    <dc:creator>LizGagne</dc:creator>
    <dc:date>2018-08-31T19:49:17Z</dc:date>
    <item>
      <title>Using markerchar to plot a repeated string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-markerchar-to-plot-a-repeated-string/m-p/491731#M129033</link>
      <description>&lt;P&gt;I'm trying to use the following code to replicate XKCD's Binary Heart comic:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* generate random binary heart similar to xkcd comic: http://xkcd.com/99/ */
data BinaryHeart;
drop Nx Ny t r;
Nx = 21; Ny = 23;
call streaminit(2142015);
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 &amp;lt; 2 - 2*sin(t) + sin(t)*sqrt(abs(cos(t))) / (sin(t)+1.4)) 
&amp;amp; (y &amp;gt; -3.5);
B = rand("Bernoulli", 0.5);
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;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd love to swap out the random binary for a specific binary string, but can't quite figure out the spacing. When I use the following, all the numbers overlap, but when I try to add spacing I get an error that SAS was expecting an arithmetic operator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* generate random binary heart similar to xkcd comic: http://xkcd.com/99/ */
data BinaryHeart;
drop Nx Ny t r;
Nx = 21; Ny = 23;
call streaminit(2142015);
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 &amp;lt; 2 - 2*sin(t) + sin(t)*sqrt(abs(cos(t))) / (sin(t)+1.4)) 
&amp;amp; (y &amp;gt; -3.5);
B=(0110110101101111011011000110110001111001);
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;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Aug 2018 19:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-markerchar-to-plot-a-repeated-string/m-p/491731#M129033</guid>
      <dc:creator>LizGagne</dc:creator>
      <dc:date>2018-08-31T19:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using markerchar to plot a repeated string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-markerchar-to-plot-a-repeated-string/m-p/491808#M129077</link>
      <description>&lt;P&gt;I guess you want to cycle on the elements of your binary string, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 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 &amp;lt; 2 - 2*sin(t) + sin(t)*sqrt(abs(cos(t))) / (sin(t)+1.4)) 
        &amp;amp; (y &amp;gt; -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;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot2.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22941i6556AE2F7FE3FF43/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot2.png" alt="SGPlot2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Playing with the length of the binary string will generate different patterns.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Sep 2018 05:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-markerchar-to-plot-a-repeated-string/m-p/491808#M129077</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-09-01T05:32:16Z</dc:date>
    </item>
  </channel>
</rss>

