<?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 Re: Reference lines by a macro in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/671303#M14034</link>
    <description>&lt;P&gt;Please post the data (in data steps like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
input grade ss group $;
datalines;
1 130 2
6 124 4
1 156 2
3 234 1
2 256 4
12 300 2
;

data other_dataset;
input grade score ref;
datalines;
1 116 1
1 118 1
1 223 2
1 224 2
1 245 2
2 118 1 
2 131 1 
2 245 2
2 246 2
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;) and the code that created the second graph.&lt;/P&gt;
&lt;P&gt;Don't forget to add the dataset you intend to use for making the code dynamic.&lt;/P&gt;
&lt;P&gt;Macro development starts with working code without macro elements.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jul 2020 08:12:58 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-07-22T08:12:58Z</dc:date>
    <item>
      <title>Reference lines by a macro</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/670887#M14026</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I hope I can explain well what I need. I have a data set as provided below.&lt;/P&gt;
&lt;P&gt;grade ss group&lt;/P&gt;
&lt;P&gt;1 130 2&lt;/P&gt;
&lt;P&gt;6 124 4&lt;/P&gt;
&lt;P&gt;1 156 2&lt;/P&gt;
&lt;P&gt;3 234 1&lt;/P&gt;
&lt;P&gt;2 256 4&lt;/P&gt;
&lt;P&gt;12 300 2&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;I want to draw an overlayed distribution with reference lines for groups 2 and 4 per 12 grades. I can use that code:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sgplot data=sample;&lt;BR /&gt;where group in ("2" , "4"); /* restrict to two groups */&lt;BR /&gt;density ss/ type=normal group=group; /* overlay density estimates */&lt;BR /&gt;refline 116 / LABEL="ref1" lineattrs=(color=red) axis=x discreteoffset=0.5;&lt;/P&gt;
&lt;P&gt;refline 223 / LABEL="ref2" lineattrs=(color=red) axis=x discreteoffset=0.5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the problem is that I have 12 grades and each grade's reference lines are different. For example for grade 1 ref1=116, ref2=223 and for grade2 ref1=118, ref2=245. I have another data set as below that has those reference lines. As you see that the reference line is the first score of each ref variable per grade.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;grade score ref&lt;/P&gt;
&lt;P&gt;1 116 1&lt;/P&gt;
&lt;P&gt;1 118 1&lt;/P&gt;
&lt;P&gt;1 223 2&lt;/P&gt;
&lt;P&gt;1 224 2&lt;/P&gt;
&lt;P&gt;1 245 2&lt;/P&gt;
&lt;P&gt;2 118 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 131 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 245 2&lt;/P&gt;
&lt;P&gt;2 246 2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, it there a way to do this with a macro?&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 08:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/670887#M14026</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2020-07-21T08:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: Reference lines by a macro</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/670891#M14027</link>
      <description>&lt;P&gt;So you need to create a series of statements like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;refline 116 / LABEL="ref1" lineattrs=(color=red) axis=x discreteoffset=0.5;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;populated from the first values of ref within the grades?&lt;/P&gt;
&lt;P&gt;I would use CALL EXECUTE to create the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set other_dataset end=done;
by grade ref;
if _n_ = 1 then call execute('
proc sgplot data=sample;
where group in ("2" , "4"); /* restrict to two groups */
density ss/ type=normal group=group;
');
if first.ref then call execute('
refline ' !! put(score,best.) !! ' / LABEL="ref' !! trim(put(ref,best.)) !! '" lineattrs=(color=red) axis=x discreteoffset=0.5;
');
if done then call execute('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 08:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/670891#M14027</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-21T08:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reference lines by a macro</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/671088#M14029</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thank you for your help. Here is what I got from the code that you provided. It is working but it's not drawing distributions per grade and it has so many lines. However, I should have only 6 lines per grade.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dustychair_0-1595347340666.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47449iCB7D69F2FC43B704/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dustychair_0-1595347340666.png" alt="dustychair_0-1595347340666.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And I should get something like below per grade.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dustychair_1-1595347423178.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47450i4938A641B44460C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dustychair_1-1595347423178.png" alt="dustychair_1-1595347423178.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 16:04:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/671088#M14029</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2020-07-21T16:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reference lines by a macro</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/671303#M14034</link>
      <description>&lt;P&gt;Please post the data (in data steps like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
input grade ss group $;
datalines;
1 130 2
6 124 4
1 156 2
3 234 1
2 256 4
12 300 2
;

data other_dataset;
input grade score ref;
datalines;
1 116 1
1 118 1
1 223 2
1 224 2
1 245 2
2 118 1 
2 131 1 
2 245 2
2 246 2
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;) and the code that created the second graph.&lt;/P&gt;
&lt;P&gt;Don't forget to add the dataset you intend to use for making the code dynamic.&lt;/P&gt;
&lt;P&gt;Macro development starts with working code without macro elements.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 08:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Reference-lines-by-a-macro/m-p/671303#M14034</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-22T08:12:58Z</dc:date>
    </item>
  </channel>
</rss>

