BookmarkSubscribeRSS Feed
albertsamaniego
Fluorite | Level 6

Hi is it possible to add gridlines on the xaxistable on the proc sgplot?

 

here's my sample code. Note that I only created a dummy data named sample data set.

 

/*create sample data*/
data sample; brand = "Brand1";count = 10;Month = 1;output; brand = "Brand1";count = 22;Month = 2;output; brand = "Brand1";count = 12;Month = 3;output; brand = "Brand2";count = 11;Month = 1;output; brand = "Brand2";count = 31;Month = 2;output; brand = "Brand2";count = 2;Month = 3;output; brand = "Brand3";count = 21;Month = 1;output; brand = "Brand3";count = 41;Month = 2;output; brand = "Brand3";count = 11;Month = 3;output; run; /*plot graph*/ proc sgplot data=sample;
vbar brand /response=count group=Month groupdisplay=CLUSTER;
xaxistable count /colorgroup=Month location=inside nostatlabel valueattrs=(size=10 weight=normal) separator;
xaxis display=(nolabel noline noticks);
yaxis display=(noline noticks) grid;
run;

The resulting graph would be like this but I'm required to add gridlines on the table underneath the bar graph.

Capture.PNG

 

 

 

2 REPLIES 2
Ksharp
Super User
data sample;
brand = "Brand1";count = 10;Month = 1;output;
brand = "Brand1";count = 22;Month = 2;output;
brand = "Brand1";count = 12;Month = 3;output;
brand = "Brand2";count = 11;Month = 1;output;
brand = "Brand2";count = 31;Month = 2;output;
brand = "Brand2";count = 2;Month = 3;output;
brand = "Brand3";count = 21;Month = 1;output;
brand = "Brand3";count = 41;Month = 2;output;
brand = "Brand3";count = 11;Month = 3;output;
run;

/*plot graph*/
proc sgplot data=sample; 
vbar brand /response=count group=Month groupdisplay=CLUSTER; 
xaxistable count /colorgroup=Month location=inside nostatlabel 
valueattrs=(size=10 weight=normal) separator; 
xaxis display=(nolabel noline noticks); yaxis display=(noline noticks) grid;
refline "Brand1" "Brand2" "Brand3"/axis=x discreteoffset=0.3;
refline "Brand1" "Brand2" "Brand3"/axis=x discreteoffset=-0.3;
refline "Brand1" "Brand2" "Brand3"/axis=x;
run;
albertsamaniego
Fluorite | Level 6

hi sorry for the confusion, what I mean is to add grid lines on the table highlighted below and not on the chart itself.

Capture.PNG

 

thanks for the reply anyway.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2315 views
  • 2 likes
  • 2 in conversation