<?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: how to apply by group processing to sganno in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/309837#M10886</link>
    <description>&lt;P&gt;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/2016/11/07/layers-vs-annotation/" target="_blank"&gt;http://blogs.sas.com/content/graphicallyspeaking/2016/11/07/layers-vs-annotation/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Nov 2016 19:52:16 GMT</pubDate>
    <dc:creator>Jay54</dc:creator>
    <dc:date>2016-11-07T19:52:16Z</dc:date>
    <item>
      <title>how to apply by group processing to sganno</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/308640#M10833</link>
      <description>&lt;P&gt;Similar to what was apparently possible with SAS&amp;nbsp;GCHART (&lt;A href="https://v8doc.sas.com/sashtml/gref/bychap.htm" target="_blank"&gt;https://v8doc.sas.com/sashtml/gref/bychap.htm&lt;/A&gt;), I would like to customize the annotation for the output from each BY group by incuding the BY&amp;nbsp;variable in the sganno data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, in the following chart, I would only like to show the Female line in the Female chart and the Male line in the Male chart ...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Line;
  infile datalines dlm='#';
  length id $ 1
			label $ 27
         textcolor $ 9
         linecolor $ 9
		y1space $ 9
		y2space $ 9;

  input id $ function $ x1 y1 label $ x2 y2 textcolor linecolor y1space $ y2space $;
datalines;
F  # text # 50 # 63 # F Average 61 Inches # . # . # blue #  # datavalue # datavalue #
F # line # 10 # 61 #   # 99 # 61 #   # blue # datavalue # datavalue #
M # text # 20 # 66 # M Average 64 Inches # . # . # blue # # datavalue # datavalue #
M # line # 10 # 64 #   # 99 # 64 #   # blue # datavalue # datavalue #
;
run;
proc sort data=sashelp.class out=class;
by sex;
run;
proc sgplot data=class sganno=Line;
by sex;
 scatter x=weight y=height;
 yaxis min=55 max=75;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5601iF75A3BE41F920D92/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="ByAnno.png" title="ByAnno.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note this is my current workaround (macro processing with a do loop), however &lt;STRONG&gt;it would be great to know if this possible by&amp;nbsp;using the BY statement&lt;/STRONG&gt;.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*See: http://support.sas.com/kb/26/155.html*/
/*http://blogs.sas.com/content/publishing/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/*/
proc sql noprint;
  select distinct sex into : sex_list separated by ' ' from class;
quit;
%macro plotBy(values);    
                                                                                                                
     /* Count the number of values in the string */                                                                                                                                   
     %let count=%sysfunc(countw(&amp;amp;values)); 

     /* Loop through the total number of values */                                                                                         
     %do i = 1 %to &amp;amp;count;                                                                                                              
      %let value=%qscan(&amp;amp;values,&amp;amp;i,%str( ));                                                                                            
        
		   proc sgplot data=class(where=(sex="&amp;amp;value")) sganno=Line(where=(id="&amp;amp;value"));
	 scatter x=weight y=height;
	 yaxis min=55 max=75;
	run;
 
     %end;                                                                                                                              
                                                                                                                                        
%mend; 
%plotBy(&amp;amp;sex_list); &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Marie&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 00:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/308640#M10833</guid>
      <dc:creator>mduarte</dc:creator>
      <dc:date>2016-11-02T00:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply by group processing to sganno</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/308642#M10834</link>
      <description>&lt;P&gt;When you are using SGPLOT, often you can get stuff done with statements and may not need annotate. &amp;nbsp;In this case, you can add the mean values to the original data set by 'Sex' and then use a reference line statement to get the result. &amp;nbsp;You can add additional data to the data set and display the text you need. &amp;nbsp;Using statement overlays is more robust, as such reference line values are sent to the axis for proper scaling. &amp;nbsp;Annotated values are not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SGPlot annotation does not have&amp;nbsp;BY variable support. &amp;nbsp;The need&amp;nbsp;has not come up due to its different architecture. &amp;nbsp;However, if the need arises, we can add that feature in a future release.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data class;&lt;BR /&gt;&amp;nbsp; set sashelp.class end=last;&lt;BR /&gt;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if last then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; call missing (name, sex, age, height, weight);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; sex='M'; Avg=64; output;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; sex='F'; Avg=61; output;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=class out=class2;&lt;BR /&gt;by sex;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=class2 uniform=yscale;&lt;BR /&gt;&amp;nbsp; by sex;&lt;BR /&gt;&amp;nbsp; scatter x=weight y=height;&lt;BR /&gt;&amp;nbsp; refline avg / label;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5602i0D7DB700652313DA/image-size/medium?v=v2&amp;amp;px=-1" border="0" alt="ScatterRefBySex.png" title="ScatterRefBySex.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 01:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/308642#M10834</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-11-02T01:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply by group processing to sganno</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/308646#M10835</link>
      <description>&lt;P&gt;Thank-you for your comprehensive reply. &amp;nbsp;That &lt;SPAN&gt;SGPlot annotation does not have&amp;nbsp;BY variable support answers my question. &amp;nbsp;&lt;/SPAN&gt;I hadn't thought of the solution you provided but not sure if it would apply to my "real" problem. &amp;nbsp;The example I gave was fabricated and not what I am working on. &amp;nbsp;In my case, I am doing something similar to: vbar = &lt;EM&gt;Australian State&lt;/EM&gt; (e.g. &amp;nbsp;QLD, NSW ...), the BY variable is &lt;EM&gt;operation typ&lt;/EM&gt;e (e.g. hip replacement, ...) and the refline is &lt;EM&gt;national average&lt;/EM&gt; (i.e., not the "by" variable, or state, average). &amp;nbsp;Also, I haven't hardcoded the national averages, but taking them from dataset itself. &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 01:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/308646#M10835</guid>
      <dc:creator>mduarte</dc:creator>
      <dc:date>2016-11-02T01:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply by group processing to sganno</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/308748#M10837</link>
      <description>&lt;P&gt;I used hard coded values for convenience to suggest how to use SGPLOT for such a graph. &amp;nbsp;Clearly, one should use something like PROC MEANS and merge the data. &amp;nbsp;I beleive you will be able to use the "layered" SGPLOT approach&amp;nbsp;for your real use case. &amp;nbsp;However, using GPLOT with the annotation is perfectly fine too. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 13:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/308748#M10837</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-11-02T13:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply by group processing to sganno</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/309837#M10886</link>
      <description>&lt;P&gt;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/2016/11/07/layers-vs-annotation/" target="_blank"&gt;http://blogs.sas.com/content/graphicallyspeaking/2016/11/07/layers-vs-annotation/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 19:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/309837#M10886</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-11-07T19:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply by group processing to sganno</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/310034#M10891</link>
      <description>Nice - confirming that your solution works for the real use case as well! Thanks again.</description>
      <pubDate>Tue, 08 Nov 2016 12:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/310034#M10891</guid>
      <dc:creator>mduarte</dc:creator>
      <dc:date>2016-11-08T12:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply by group processing to sganno</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/310103#M10895</link>
      <description>&lt;P&gt;If the average line is a national average, not part of the BY variable, it is likely straightforward. &amp;nbsp;You could compute the average into&amp;nbsp;a macro variable and use that with the REFLINE statement.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2016 14:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-apply-by-group-processing-to-sganno/m-p/310103#M10895</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-11-08T14:54:03Z</dc:date>
    </item>
  </channel>
</rss>

