BookmarkSubscribeRSS Feed
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10

Hello,

 

I am trying to add a vertical border between bars for q1 and q2 so that the bars for q1 are set off from the other grouped bars. If my x-axis were continuous, I would just use the REFLINE statement, but how do I do this when my x-axis is discrete? I want the line to extend the length of the y-axis. Thank you!

 

data have;
input year $ var $ value lowerci upperci;
cards;
2018 q1 3.4 3.2 3.6
2019 q1 3.9 3.8 4.0
2018 q2 2.1 2.0 2.2
2019 q2 3.0 2.8 3.2
2018 q3 1.8 1.5 2.1
2019 q3 1.4 1.3	1.5
;
run;

proc sgplot data=have;
  vbarparm category=var response=value/  group=year limitlower=lowerci groupdisplay=cluster  limitupper=upperci barwidth=.6 tip=(value) ;
  yaxis min=0 max=4 minor values= (0 to 4 by .5) grid  label="Strongly disagree : Strongly agree";
  xaxis label = ' ';
  run;

 

 

1 REPLY 1
ballardw
Super User

Not the slickest but:

 

proc format library=work;
value $q 
'q1.5' = ' '
other = [$2.]
;
run;

proc sgplot data=have;
  vbarparm category=var response=value/  group=year limitlower=lowerci groupdisplay=cluster  
                                       limitupper=upperci barwidth=.6 tip=(value);
  refline 'q1.5' /axis=x ;
  yaxis min=0 max=4 minor values= (0 to 4 by .5) grid  label="Strongly disagree : Strongly agree";
  xaxis label = ' ' values=('q1' 'q1.5' 'q2' 'q3') valuesformat=$q.;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 300 views
  • 1 like
  • 2 in conversation