<?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 Superimpose a graph in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30047#M876</link>
    <description>How can I superimpose a scatterplot to a boxplot?</description>
    <pubDate>Mon, 14 Dec 2009 15:04:57 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-12-14T15:04:57Z</dc:date>
    <item>
      <title>Superimpose a graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30047#M876</link>
      <description>How can I superimpose a scatterplot to a boxplot?</description>
      <pubDate>Mon, 14 Dec 2009 15:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30047#M876</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-14T15:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Superimpose a graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30048#M877</link>
      <description>Assuming you have SAS 9.2, you can do this easily using the Graph Template Language.  Here is a simple example:&lt;BR /&gt;
&lt;BR /&gt;
proc template;&lt;BR /&gt;
define statgraph boxscatter;&lt;BR /&gt;
begingraph;&lt;BR /&gt;
layout overlay;&lt;BR /&gt;
  boxplot x=age y=height;&lt;BR /&gt;
  scatterplot x=age y=weight / yaxis=y2;&lt;BR /&gt;
endlayout;&lt;BR /&gt;
endgraph;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sgrender data=sashelp.class template=boxscatter; run;</description>
      <pubDate>Mon, 14 Dec 2009 15:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30048#M877</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2009-12-14T15:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Superimpose a graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30049#M878</link>
      <description>Here's how with good-old traditional gplot (the example generates some fake/random data, and also plots it)...&lt;BR /&gt;
&lt;BR /&gt;
Assuming you're using the same data for the boxplot and the scatter plot (ie, you just want to also show a scatter plot of the points that the boxplot is based on), this can be very easily done by putting the y*x on the plot statement twice, and using a different plot interpolation for each:&lt;BR /&gt;
&lt;BR /&gt;
data foo;&lt;BR /&gt;
 do x=0 to 10 by 1;&lt;BR /&gt;
  do i=1 to 20;&lt;BR /&gt;
   y=rannor(23749);&lt;BR /&gt;
   output;&lt;BR /&gt;
   end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
symbol1 v=none i=box color=blue;&lt;BR /&gt;
symbol2 v=dot height=.01 i=none color=red;&lt;BR /&gt;
proc gplot data=foo;&lt;BR /&gt;
 plot y*x=1 y*x=2 / overlay;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Or, you can plot totally separate data (that isn't necessarily confined to having the exact same x-values as the boxplot), using a technique such as this...&lt;BR /&gt;
&lt;BR /&gt;
data foo;&lt;BR /&gt;
 do x=0 to 10 by .1;&lt;BR /&gt;
  do i=1 to 20;&lt;BR /&gt;
   y=rannor(23749);&lt;BR /&gt;
   output;&lt;BR /&gt;
   end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data foo; set foo;&lt;BR /&gt;
 x_rounded=round(x);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
symbol1 v=none i=box color=blue;&lt;BR /&gt;
symbol2 v=dot height=.01 i=none color=red;&lt;BR /&gt;
proc gplot data=foo;&lt;BR /&gt;
 plot y*x_rounded=1 y*x=2 / overlay;&lt;BR /&gt;
run;</description>
      <pubDate>Mon, 14 Dec 2009 15:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30049#M878</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2009-12-14T15:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Superimpose a graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30050#M879</link>
      <description>Thanks, for the code.  Do I have problem with this code if the data sources for the plots are not same.  I also need to include a by variable in the boxplot.  In addition, I got the following message in the log:&lt;BR /&gt;
&lt;BR /&gt;
1143  proc template;&lt;BR /&gt;
1144  define statgraph boxscatter;&lt;BR /&gt;
1145  begingraph;&lt;BR /&gt;
      ----------&lt;BR /&gt;
      180&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
1146  layout overlay;&lt;BR /&gt;
1147  boxplot x=age y=height;&lt;BR /&gt;
1148  scatterplot x=age y=weight / yaxis=y2;&lt;BR /&gt;
1149  endlayout;&lt;BR /&gt;
1150  endgraph;&lt;BR /&gt;
      --------&lt;BR /&gt;
      1&lt;BR /&gt;
WARNING 1-322: Assuming the symbol END was misspelled as endgraph.&lt;BR /&gt;
1151  end;&lt;BR /&gt;
WARNING: Object will not be saved.&lt;BR /&gt;
1152  run;&lt;BR /&gt;
NOTE: PROCEDURE TEMPLATE used (Total process time):&lt;BR /&gt;
      real time           0.21 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
WARNING: Errors were produced.&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
1153&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
1154  proc sgrender data=sashelp.class template=boxscatter; run;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Procedure SGRENDER not found.&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
NOTE: PROCEDURE SGRENDER used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds</description>
      <pubDate>Mon, 14 Dec 2009 15:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30050#M879</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-14T15:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Superimpose a graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30051#M880</link>
      <description>Based on your log output, you must not have SAS 9.2.  Robert's gplot approach should work fine for you.  As a side note, the SGRENDER procedure does support BY-groups.  The BY-group variable(s) is not specified in the template.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
Dan</description>
      <pubDate>Mon, 14 Dec 2009 16:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30051#M880</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2009-12-14T16:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Superimpose a graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30052#M881</link>
      <description>Correction on my last post, you probably have 9.2 phase 1.  Does the code run for you if you remove the BEGINGRAPH and ENDGRAPH?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
Dan</description>
      <pubDate>Mon, 14 Dec 2009 16:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30052#M881</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2009-12-14T16:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Superimpose a graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30053#M882</link>
      <description>In addition, you may need to use this bit of code instead of SGRENDER:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
set sashelp.class;&lt;BR /&gt;
file print ods=(template="boxscatter");&lt;BR /&gt;
put _ods_;&lt;BR /&gt;
run;</description>
      <pubDate>Mon, 14 Dec 2009 16:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30053#M882</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2009-12-14T16:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Superimpose a graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30054#M883</link>
      <description>This code works.  Thanks a lot.</description>
      <pubDate>Mon, 14 Dec 2009 18:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Superimpose-a-graph/m-p/30054#M883</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-14T18:15:11Z</dc:date>
    </item>
  </channel>
</rss>

