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
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;
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.