BookmarkSubscribeRSS Feed
sasuerrr
Calcite | Level 5

In the below image for clustered bar graph, I want to align the tickmarks between the two clustered bars. For some of them I see aligned and for others tickmark are not aligned between the bars. I am using SAS 9.4 sgplot. Are there any options that would make this alignment.

 

 

Thank you!tickmarks.JPG

3 REPLIES 3
pink_poodle
Barite | Level 11

You would need to provide the exact values for the x-axis tickmarks in the VALUES= option of the XAXIS statement [1, 2].

It is possible to control the spacing of the tick marks on the time axis. The following statement uses the XAXIS statement to tell PROC SGPLOT to mark the axis at the start of each quarter:

xaxis values=('1jan90'd to '1jul91'd by qtr);

 [2]

 

References

 

[1] PROC SGPLOT: XAXIS, X2AXIS, YAXIS, Y2AXIS Statements

 

[2] Using PROC SGPLOT: Working with Time Series Data

ballardw
Super User

At least provide the code you are using now and some example data.

 

Also does your data always have exactly 2 bars in each "cluster"? If not then this may be a meaningless task. Depending on your data you may also appear to have "missing" bars if the value for the height is 0.

 

Example of "missing bar".

data example;
   input xvar groupvar responsevar;
datalines;
1  1  3
1  2  4
2  1  6
2  2  0
2  3  2
;
run;

proc sgplot data=example;
   vbar xvar/group=groupvar response= responsevar
             groupdisplay=cluster
   ;
run;
sasuerrr
Calcite | Level 5

Below is the code.

 

proc template;
define statgraph vbarplot;
dynamic _ticklist_;
begingraph / collation=binary;
entrytitle '';
layout overlay / xaxisopts=(type=Discrete discreteOpts=(tickValueList=_ticklist_ tickValueListPolicy=Union tickvaluefitpolicy=rotate) )
yaxisopts=(labelFitPolicy=Split label = "Count" ) cycleattrs=true;
barchart X=chgcatn Y=respvar / primary=true Group=grpname NAME="VBAR" groupdisplay=cluster ;
discretelegend "VBAR"/ location=outside halign=center valign=bottom title=" ";
endlayout;
endgraph;
end;
run;

 

 

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1132 views
  • 1 like
  • 3 in conversation