<?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 Adding a label to refline in proc sgpanel when refline is a date var in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Adding-a-label-to-refline-in-proc-sgpanel-when-refline-is-a-date/m-p/862568#M23564</link>
    <description>&lt;P&gt;Hello, I am using proc sgpanel to plot encounters over time for 2 variables (disease rates) across 4 groups (hospitals).&amp;nbsp; Each hospital has a different date for when they switch health records, which I've stored in the variable 'mgen_date'.&amp;nbsp; The reference line shows up fine, but I can't figure how to apply a label to it.&amp;nbsp; When I try the code below it doesn't apply the label and gives the warning: "&lt;/P&gt;&lt;PRE&gt;proc sgpanel data=XXXX;
	where fisc_monyr &amp;gt;= '01Nov2015'd;
	panelby hotel / layout=rowlattice onepanel
		novarname uniscale=column;
	series x=fisc_monyr y=xxx / legendlabel='Any XXX' lineattrs=(color=black);
	series x=fisc_monyr y=yyy / legendlabel='YYY XXX' lineattrs=(color=crimson);
	colaxis grid
			values=('01Nov2015'd to '01Oct2021'd) 
			label="Month-Year"
			display=all interval=semiyear  valuesrotate=diagonal notimesplit;
	rowaxis grid
			label="Cars per month";
	format fisc_monyr monyy..;
	/*Add refline for tanker date*/
	refline tanker_date / axis=x label="Mardi Gras Start" lineattrs=(color=gray
										pattern=shortDash
										thickness=1)
										transparency=0.1;
run;&lt;/PRE&gt;&lt;P&gt;NOTE: CURVELABEL='MGEN Start' is invalid. The option value cannot be a string when a column of reference lines is plotted. The label will not be drawn."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the graph:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bhando_0-1678133182713.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81120iED56FA343D874ECF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bhando_0-1678133182713.png" alt="Bhando_0-1678133182713.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I also have questions about how to format the x-axis, but I'll save that for later.&amp;nbsp; Thanks so much!&lt;/P&gt;&lt;P&gt;Ben&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2023 23:28:49 GMT</pubDate>
    <dc:creator>Bhando</dc:creator>
    <dc:date>2023-03-06T23:28:49Z</dc:date>
    <item>
      <title>Adding a label to refline in proc sgpanel when refline is a date var</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-a-label-to-refline-in-proc-sgpanel-when-refline-is-a-date/m-p/862568#M23564</link>
      <description>&lt;P&gt;Hello, I am using proc sgpanel to plot encounters over time for 2 variables (disease rates) across 4 groups (hospitals).&amp;nbsp; Each hospital has a different date for when they switch health records, which I've stored in the variable 'mgen_date'.&amp;nbsp; The reference line shows up fine, but I can't figure how to apply a label to it.&amp;nbsp; When I try the code below it doesn't apply the label and gives the warning: "&lt;/P&gt;&lt;PRE&gt;proc sgpanel data=XXXX;
	where fisc_monyr &amp;gt;= '01Nov2015'd;
	panelby hotel / layout=rowlattice onepanel
		novarname uniscale=column;
	series x=fisc_monyr y=xxx / legendlabel='Any XXX' lineattrs=(color=black);
	series x=fisc_monyr y=yyy / legendlabel='YYY XXX' lineattrs=(color=crimson);
	colaxis grid
			values=('01Nov2015'd to '01Oct2021'd) 
			label="Month-Year"
			display=all interval=semiyear  valuesrotate=diagonal notimesplit;
	rowaxis grid
			label="Cars per month";
	format fisc_monyr monyy..;
	/*Add refline for tanker date*/
	refline tanker_date / axis=x label="Mardi Gras Start" lineattrs=(color=gray
										pattern=shortDash
										thickness=1)
										transparency=0.1;
run;&lt;/PRE&gt;&lt;P&gt;NOTE: CURVELABEL='MGEN Start' is invalid. The option value cannot be a string when a column of reference lines is plotted. The label will not be drawn."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the graph:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bhando_0-1678133182713.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81120iED56FA343D874ECF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bhando_0-1678133182713.png" alt="Bhando_0-1678133182713.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I also have questions about how to format the x-axis, but I'll save that for later.&amp;nbsp; Thanks so much!&lt;/P&gt;&lt;P&gt;Ben&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 23:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-a-label-to-refline-in-proc-sgpanel-when-refline-is-a-date/m-p/862568#M23564</guid>
      <dc:creator>Bhando</dc:creator>
      <dc:date>2023-03-06T23:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a label to refline in proc sgpanel when refline is a date var</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-a-label-to-refline-in-proc-sgpanel-when-refline-is-a-date/m-p/862572#M23565</link>
      <description>&lt;P&gt;Per the documentation of the REFLINE statement for SGpanel:&lt;/P&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV class="xis-procStatement"&gt;
&lt;DIV class="xis-procStatementSyntax"&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-optionalArgGroup"&gt;
&lt;DIV id="p02olf6rlh5jzdn0zuwpdc9w3t46" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;DIV id="p0dg3nuzm3rlawn12w1nvia708pk" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;a text string for the label value.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-restriction"&gt;Restriction&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;The label string does not apply when a variable is used for the REFLINE value. In that situation, the label string is ignored and a message is written to the log.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to add other text then you could add a variable to the data set to use as the Label= variable in the refline. That value could be different for each Panelby value. One way:&lt;/P&gt;
&lt;PRE&gt;data plotclass;
   set sashelp.class;
   if sex='F' then do;
       refage=12;
       reflabel='Female Refline';
   end;
   else do;
      refage=13;
      reflabel='Male reference';
   end;
run;


proc sgpanel data=plotclass;
   panelby sex;
   scatter x=age y=weight;
   refline refage /axis=x label=reflabel;
run;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 06 Mar 2023 20:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-a-label-to-refline-in-proc-sgpanel-when-refline-is-a-date/m-p/862572#M23565</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-06T20:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a label to refline in proc sgpanel when refline is a date var</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-a-label-to-refline-in-proc-sgpanel-when-refline-is-a-date/m-p/862591#M23566</link>
      <description>This worked! I wouldn't have thought of this. Thanks so much for your time and expertise, ballardw</description>
      <pubDate>Mon, 06 Mar 2023 23:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-a-label-to-refline-in-proc-sgpanel-when-refline-is-a-date/m-p/862591#M23566</guid>
      <dc:creator>Bhando</dc:creator>
      <dc:date>2023-03-06T23:11:23Z</dc:date>
    </item>
  </channel>
</rss>

