BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Q1983
Lapis Lazuli | Level 10

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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 

--
Paige Miller
DanH_sas
SAS Super FREQ

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;

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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