<?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: Plot Multiple Y Axis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882776#M348781</link>
    <description>&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2012/01/16/the-more-the-merrier/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2012/01/16/the-more-the-merrier/&lt;/A&gt;</description>
    <pubDate>Wed, 28 Jun 2023 11:43:20 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-06-28T11:43:20Z</dc:date>
    <item>
      <title>Plot Multiple Y Axis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882745#M348762</link>
      <description>&lt;P&gt;I get 4 correlated lines, with SGPLOT(picture below).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Y2AXIS allows to plot 2-Y-Axis; It helps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BUT BETTER is with 4-Y-Axis... HOW TO DO THAT?! Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot24.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85430i5C99B0265A044925/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot24.png" alt="SGPlot24.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 07:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882745#M348762</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2023-06-28T07:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Plot Multiple Y Axis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882776#M348781</link>
      <description>&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2012/01/16/the-more-the-merrier/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2012/01/16/the-more-the-merrier/&lt;/A&gt;</description>
      <pubDate>Wed, 28 Jun 2023 11:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882776#M348781</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-28T11:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Plot Multiple Y Axis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882779#M348783</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
Why not use multi panel to polt these four series?
*/
proc sort data= sashelp.stocks out=have;
by date;
run;
data want;
merge have(keep=stock date close rename=(close=IBM) where=(stock='IBM') in=ina) 
      have(keep=stock date close rename=(close=Intel) where=(stock='Intel') in=inb) 
      have(keep=stock date close rename=(close=Microsoft) where=(stock='Microsoft')) ;
by date;
if ina then IBM=IBM+10000;
if inb then Intel=Intel+1000;
drop stock;
run;
proc sgscatter data=want;
compare x=date y=(ibm intel microsoft)/markerattrs=(size=0) join spacing=4;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1687952743272.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85435i3A06E6DB2927FE5A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1687952743272.png" alt="Ksharp_0-1687952743272.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 11:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882779#M348783</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-28T11:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Plot Multiple Y Axis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882921#M348857</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Here is an example*/
/*make a sample data*/
data have;
call streaminit(123);
do x=1 to 100;
 a=rand('integer',1000,2000);  a=1456;
 b=rand('integer',40000,80000);  b=63457;
 c=rand('integer',100000,150000); c=140932;
 d=rand('integer',28000,38000); 
 output;
end;
run;

data axis;
 do a=1000 to 2000 by 100;
   label_a=a;
   label_b=40000+  (80000-40000) * (a-1000)/(2000-1000);
   label_c=100000+ (150000-100000) * (a-1000)/(2000-1000);
   output;
 end;
 format label_a label_b label_c best10.;
run;
proc sort data=have;by a;run;
data want;
 merge have axis;
 by a;
 _b=1000+ (2000-1000)* (b-40000)/(80000-40000) ;
 _c=1000+ (2000-1000)* (c-100000)/(150000-100000) ;
run;
proc sort data=want;by x;run;
options missing=' ';
proc sgplot data=want;
series x=x y=a/lineattrs=(color=red);
series x=x y=_b/lineattrs=(color=blue);
series x=x y=_c/lineattrs=(color=green)  ;
series x=x y=d/lineattrs=(color=purple) y2axis;

yaxis values=(1000 to 2000  by 100) display=(novalues nolabel)  ;
*labelpos=top labelattrs=(color=red size=10) valueattrs=(color=red size=10);

yaxistable  label_c/position=left labelattrs=(color=green size=10) valueattrs=(color=green size=10) ;
yaxistable  label_b/position=left labelattrs=(color=blue size=10) valueattrs=(color=blue size=10);
yaxistable  label_a/position=left labelattrs=(color=red size=10) valueattrs=(color=red size=10);
y2axis labelpos=top labelattrs=(color=purple size=10) valueattrs=(color=purple size=10);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1688039231363.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85456iCA56716F3ABDECF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1688039231363.png" alt="Ksharp_0-1688039231363.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 11:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882921#M348857</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-29T11:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Plot Multiple Y Axis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882946#M348872</link>
      <description>&lt;P&gt;I like KSharp's panel alternative. You can use PROC TRANSPOSE to convert the data from wide to long, then use PROC SGPANEL. Here is the method on the data in the blog post:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data torque;
  input Torque RPM Amps Eff;
  RPM=RPM/50;
  Amps=Amps / 5;
  datalines;
10   4000   95  80
20   3300  130  84
30   2800  160  86.5
40   2450  200  87.5
50   2200  230  87.6
60   2000  255  87.7
70   1840  285  87.5
80   1700  320  87
90   1600  345  86.2
100  1510  375  85.7
110  1470  395  85
120  1400  420  84
130  1400  440  83
140  1380  460  82
150  1380  480  81
;

/* Transpose the variables from wide to long format:
   https://blogs.sas.com/content/iml/2011/01/31/reshaping-data-from-wide-to-long-format.html
*/
proc transpose data=torque 
   out=long(rename=(Col1=Value)) name=VarName;                    
   by Torque;
   var RPM Amps Eff; /* make a row for these variables */
run;

proc sgpanel data=long;
   panelby VarName / columns=1 onepanel novarname;
   series x=Torque y=Value;
   rowaxis grid;
   colaxis grid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Jun 2023 14:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-Multiple-Y-Axis/m-p/882946#M348872</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-06-29T14:24:26Z</dc:date>
    </item>
  </channel>
</rss>

