BookmarkSubscribeRSS Feed
KrisNori
Obsidian | Level 7

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           

3 REPLIES 3
PGStats
Opal | Level 21

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
KrisNori
Obsidian | Level 7

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;

DanH_sas
SAS Super FREQ

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2246 views
  • 0 likes
  • 3 in conversation