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
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
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
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.