<?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: SGPlot RefLine label and labelattrs in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109986#M4136</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another alternative is to use the macro variable to drive an annotation label. That way, you do not have to do any style manipulation. You also get the benefit of text wrapping support in the annotation facility. As a side note, the LABELATTRS issue with REFLINEs is fixed in the next release. Here is the code for the anno approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE lang="SAS"&gt;proc sql;
 create table myclass as 
&amp;nbsp;&amp;nbsp; select age,height 
&amp;nbsp;&amp;nbsp; from sashelp.class
 ;
 select mean(height) into :mHeight 
&amp;nbsp;&amp;nbsp; from sashelp.class
 ;
quit;

data anno;
function="text"; x1=101; y1=&amp;amp;mHeight; x1space="wallpercent"; y1space="datavalue"; anchor="left"; 
label="Mean Height"; textcolor="green";
run;

proc sgplot data=myclass pad=(right=10%) sganno=anno;
&amp;nbsp; scatter x=age y=height;
&amp;nbsp; refline &amp;amp;mHeight /axis=y lineattrs=(color=green);
run;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Dec 2012 16:52:20 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2012-12-28T16:52:20Z</dc:date>
    <item>
      <title>SGPlot RefLine label and labelattrs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109984#M4134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I'm using SGPLOT to make a scatterplot that has a data driven reference line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having 2 problems:&lt;/P&gt;&lt;P&gt;1. When I try to label the reference line, I get a note that means&amp;nbsp; (I think) you are not allowed to label reference lines when the value of the reference line is a variable.&lt;/P&gt;&lt;P&gt;2. Ignoring that, if I use a value for a reference line (rather than a variable), and try to use the LABELATTRS= option to make the label the same color as the line, the LABELATTRS option causes as error (unknown option) even though I'm on 9.3.1M2 (on linux).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample code below:&lt;/P&gt;&lt;PRE&gt;proc sql;
 create table myclass as 
&amp;nbsp;&amp;nbsp; select age,height,mean(height) as mHeight 
&amp;nbsp;&amp;nbsp; from sashelp.class
 ;
quit;

proc sgplot data=myclass;
&amp;nbsp; scatter x=age y=height;
&amp;nbsp; refline mHeight /axis=y label="Mean Height" lineattrs=(color=red) ;
&amp;nbsp; refline 65 /axis=y label="Another ref line" lineattrs=(color=green) /*labelattrs=(color=green)*/;
run;

&lt;/PRE&gt;&lt;P&gt;The inability to label a reference line when the value is driven by a variable seems odd.&amp;nbsp; Since my variable is a constant, I can work around it in this case by creating a macro variable with the value.&amp;nbsp; But of course not all reference lines are constant...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure why LABELATTRS is not working.&amp;nbsp; Before I dive into in-line formatting or the style template to try forcing the font color that way, was wondering if there were any thoughts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2012 13:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109984#M4134</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2012-12-28T13:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: SGPlot RefLine label and labelattrs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109985#M4135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; LABELATTRS is for Axis labels, I don't think it was designed to "touch" reference line labels.&amp;nbsp; I'm not sure you can change the label color in the REFLINE statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Don't bother with in-line formatting, it was never designed to work with the ODS GRAPHICS or SAS/GRAPH -- the only piece that works is the UNICODE function with ODS GRAPHICS to insert symbols like alpha and mu.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Also, about the style element you would change to impact the reference lines. I'm not sure there is a separate style element for the axis ticks versus the reference line labels, which leads me to believe that they are all meant to be black and not draw too much attention to one line or label over the other lines or labels. If you try the code below, you will end up getting all the various labels cyan (#1) or getting the X and Y axis different colors (#2). You might have to work with ANNOTATE and ODS GRAPHICS to get differently colored text for the reference lines. Or just live with plain old black text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc sql noprint;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; select mean(height) as mHeight into :mheight&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; from sashelp.class&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt; ;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;%put mean height = &amp;amp;mheight;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;title;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods path work.tmp(update) sasuser.templat(update)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sashelp.tmplmst(read);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc template;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define style styles.mygraf;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; parent=styles.statistical;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; class GraphValueText /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; font = GraphFonts('GraphValueFont')&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color=cyan;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; end;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods listing close;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html path='c:\temp' (url=none)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file='trylabel.html' style=styles.mygraf;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc sgplot data=sashelp.class;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title '1) Using STYLE template everything is CYAN';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; scatter x=age y=height;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; refline &amp;amp;mheight /axis=y label="Mean Height" lineattrs=(color=red) ;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; refline 65 /axis=y label="Another ref line" lineattrs=(color=green);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc sgplot data=sashelp.class;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title '2) Override XAXIS and YAXIS Values';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; scatter x=age y=height;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; refline &amp;amp;mheight /axis=y label="Mean Height" lineattrs=(color=red) ;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; refline 65 /axis=y label="Another ref line" lineattrs=(color=green);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; xaxis&amp;nbsp; labelattrs=(color=purple) valueattrs=(color=purple);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; yaxis&amp;nbsp; labelattrs=(color=blue) valueattrs=(color=blue);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html close;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2012 16:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109985#M4135</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2012-12-28T16:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: SGPlot RefLine label and labelattrs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109986#M4136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another alternative is to use the macro variable to drive an annotation label. That way, you do not have to do any style manipulation. You also get the benefit of text wrapping support in the annotation facility. As a side note, the LABELATTRS issue with REFLINEs is fixed in the next release. Here is the code for the anno approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE lang="SAS"&gt;proc sql;
 create table myclass as 
&amp;nbsp;&amp;nbsp; select age,height 
&amp;nbsp;&amp;nbsp; from sashelp.class
 ;
 select mean(height) into :mHeight 
&amp;nbsp;&amp;nbsp; from sashelp.class
 ;
quit;

data anno;
function="text"; x1=101; y1=&amp;amp;mHeight; x1space="wallpercent"; y1space="datavalue"; anchor="left"; 
label="Mean Height"; textcolor="green";
run;

proc sgplot data=myclass pad=(right=10%) sganno=anno;
&amp;nbsp; scatter x=age y=height;
&amp;nbsp; refline &amp;amp;mHeight /axis=y lineattrs=(color=green);
run;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2012 16:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109986#M4136</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2012-12-28T16:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: SGPlot RefLine label and labelattrs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109987#M4137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cynthia and Dan have provided alternate solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have run into the 80-20 limitation for SGPlot.&amp;nbsp; If you are willing to venture into GTL, here is the equivalent GTL code to get what you want.&amp;nbsp; Note, when the value(s) for the ReferenceLine comes from a variable, the label also needs to come from a variable (since there may be multiple lines).&amp;nbsp; If you have a label for each value, it will look dark due to overplotting of the name repeatedly.&amp;nbsp; So, it may be useful to only add the label when needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt; create table myclass as &lt;BR /&gt;&amp;nbsp;&amp;nbsp; select age,height,mean(height) as mHeight &lt;BR /&gt;&amp;nbsp;&amp;nbsp; from sashelp.class&lt;BR /&gt; ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*--Add Label--*/&lt;BR /&gt;data myclass2;&lt;BR /&gt;&amp;nbsp; set myclass;&lt;BR /&gt;&amp;nbsp; length mHeightLabel $12;&lt;BR /&gt;&amp;nbsp; if _n_ eq 1 then mHeightLabel='Mean Height';&lt;BR /&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*--Define template--*/&lt;/P&gt;&lt;P&gt;proc template;&lt;BR /&gt;&amp;nbsp; define statgraph RefLineLabel;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; begingraph;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrytitle 'Height by Age for all Students';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layout overlay;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scatterplot x=age y=height / group=sex name='a';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; referenceline y=mheight / curvelabel=mHeightLabel lineattrs=(color=green) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curvelabellocation=inside curvelabelattrs=(color=green);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endlayout;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; endgraph;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*--Create Graph--*/&lt;BR /&gt;ods listing;&lt;BR /&gt;ods graphics / reset width=5in height=3in imagename='RefLineLabel';&lt;BR /&gt;proc sgrender data=myclass2 template=RefLineLabel;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="2870" alt="RefLineLabel.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/2870_RefLineLabel.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2012 17:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109987#M4137</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2012-12-28T17:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: SGPlot RefLine label and labelattrs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109988#M4138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, many thanks to you all!&amp;nbsp; (didn't I hear that SAS was closed for the holidays? : )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Really appreciate the alternate solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sanjay and Dan, I have your Statistical Graphics Procedures by Example book out on my desk today, it has been a great introduction to SG procs.&amp;nbsp; So thanks for that as well.&amp;nbsp; (And Sanjay's SGRENDER solution might encourage me to get back into Warren Kuhfeld's GTL book, which I figured I'd dive into after spending more time with basic SGPLOT...&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2012 17:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-RefLine-label-and-labelattrs/m-p/109988#M4138</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2012-12-28T17:17:41Z</dc:date>
    </item>
  </channel>
</rss>

