Data visualization with SAS programming

Desire multiple axis results on same graph

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 131
Accepted Solution

Desire multiple axis results on same graph

data a;

input MONTH SALES RETURNS;

datalines;

1 52 22

2 16 17

3 78 66

4 14 10

5 26 0

6 31 12

7 92 66

8 19 9

9 18 8

10 22 14

11 84 14

12 93 23

;

run;

/* Use the POINTLABEL option to label the plot points */

symbol1 interpol=join value=dot color=vibg height=1.3

pointlabel=(height=10pt '#sales');

/*symbol1 interpol=join value=dot color=vibg height=1.3

pointlabel=(height=10pt '#RETURNS');*/

title1 'Using the POINTLABEL Option with GPLOT';

axis1 offset=(4,4) minor=none;

axis2 offset=(2,2) minor=none;

 

proc gplot data=a;

plot sales*month / haxis=axis1 vaxis=axis2 noframe;

plot RETURNS*month / haxis=axis1 vaxis=axis2 noframe;

run;

quit;

 

It produces two graphs, one for Sales*Month and Returns*Month where *=By.

I want to produce one grpah with sales and returns on the same graph.  I need the sales to be in green (color=vibg) and the returns in red,  I guess its color=vibr.  I want to know how I would get both measures on the same graph


Accepted Solutions
Solution
4 weeks ago
Trusted Advisor
Posts: 1,496

Re: Desire multiple axis results on same graph

[ Edited ]

Probably you want to use the PLOT2 command

 

plot2 RETURNS*month / haxis=axis1 vaxis=axis2 noframe;

and the SYMBOL2 command where you assing the color vibr 

View solution in original post


All Replies
Solution
4 weeks ago
Trusted Advisor
Posts: 1,496

Re: Desire multiple axis results on same graph

[ Edited ]

Probably you want to use the PLOT2 command

 

plot2 RETURNS*month / haxis=axis1 vaxis=axis2 noframe;

and the SYMBOL2 command where you assing the color vibr 

SAS Super FREQ
Posts: 889

Re: Desire multiple axis results on same graph

Here are a couple of options for you to do straight overlays with GPLOT and SGPLOT. If you want secondary Y axis support, do what Paige said for GPLOT or use the Y2AXIS option on the "returns" SERIES plot.

 

/* Use the POINTLABEL option to label the plot points */
symbol1 interpol=join value=dot color=vibg height=1.3
pointlabel=(height=10pt '#sales');
symbol2 interpol=join value=dot color=red  height=1.3
pointlabel=(height=10pt '#RETURNS');
title1 'Using the POINTLABEL Option with GPLOT';
axis1 offset=(4,4) minor=none;
axis2 offset=(2,2) minor=none;

proc gplot data=a;
plot sales*month returns*month / overlay haxis=axis1 vaxis=axis2 noframe;
run;
quit;

/* The AXIS and SYMBOL statements do not apply here */
title1 'Using the DATALABEL Option with SGPLOT';
proc sgplot data=a;
series x=month y=sales / markers lineattrs=(color=vibg) markerattrs=(color=vibg symbol=circlefilled)
                         markerattrs=(color=vibg symbol=circlefilled) datalabel;
series x=month y=returns / markers lineattrs=(color=red) markerattrs=(color=red symbol=circlefilled)
                         markerattrs=(color=red symbol=circlefilled) datalabel;
run;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 84 views
  • 2 likes
  • 3 in conversation