Data visualization with SAS programming

Highlight a point in the SGPLOT

Reply
Occasional Contributor
Posts: 17

Highlight a point in the SGPLOT

[ Edited ]

Hi,

 

I am working on a SG plot as shown below. I want to highlight a particular sale value based on a business condition. The data set Plot_table is shown below. Sales value with Indicator value 'Y' should be highlighted in a different color.

 

Please help.

 

 

PROC SGPLOT DATA=plot_table;
SERIES X=store_name Y=sales/ lineattrs=(color=BIB pattern=3) legendlabel='Store Name' markers markerattrs=(color=BIB size=8 symbol=Square);

 

TITLE "Store Sales";
YAXIS LABEL="Sales";
XAXIS LABEL="Store Name";

RUN;

 

Store_name            Sales                  Indicator

========================================

A                              1000            

A                              2000           

A                              3000                       Y

A                              4000           

Respected Advisor
Posts: 4,802

Re: Highlight a point in the SGPLOT

Try this:

 

PROC SGPLOT DATA=plot_table noautolegend;
STYLEATTRS datacontrastcolors=(BIB RED);
SERIES X=store_name Y=sales/ lineattrs=(color=BIB pattern=3) markers markerattrs=(size=8 symbol=Square) group=Indicator;
 
TITLE "Store Sales";
YAXIS LABEL="Sales";
XAXIS LABEL="Store Name";
RUN;
PG
Occasional Contributor
Posts: 17

Re: Highlight a point in the SGPLOT

[ Edited ]

Hi PG Stats,

 

It didn't work. 

 

Also, I tried some thing else using proc template. It changed the appearance of the marker (Square with circle inside it for Indicator and Square with ¥ inside it for others), not the color. But that's hardly noticeable.

 

It's my first time using SGPLOT, so pls ignore if something looks redundant.

 

PROC template;
DEFINE style styles.symbols;
parent=styles.default;
style graphdata1 /
contrastcolor=blue;
style graphdata2 /
contrastcolor=red;
end;
RUN;

 

PROC SGPLOT DATA=plot_table;
SERIES X=store_name Y=sales/ lineattrs=(color=BIB pattern=3) legendlabel='Store Name' markers markerattrs=(color=BIB size=8 symbol=Square);

scatter x=store_name Y=sales/Group= Indicator

 

TITLE "Store Sales";
YAXIS LABEL="Sales";
XAXIS LABEL="Store Name";

RUN;

SAS Super FREQ
Posts: 925

Re: Highlight a point in the SGPLOT

[ Edited ]

For this case, you will want to plot the scatter points separately from the series plot so that you can group the scatter points based on the "indicator".

 

PROC SGPLOT DATA=plot_table;
SERIES X=store_name Y=sales/ lineattrs=(color=BIB pattern=3) legendlabel='Store Name' );
SCATTER X=store_name Y=sales/ markerattrs=(size=8 symbol=Square) group=indicator;
 
TITLE "Store Sales";
YAXIS LABEL="Sales";
XAXIS LABEL="Store Name";
RUN;

 

Hope this helps!

Dan

Ask a Question
Discussion stats
  • 3 replies
  • 213 views
  • 0 likes
  • 3 in conversation