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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 1870 views
  • 0 likes
  • 3 in conversation