Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
karlbang
Obsidian | Level 7

I am making a HIGHLOW plot

data w;
	input x y _ $;
	datalines;
    -2.460 17 A
    -0.977 12 A
    0.014 18 A
    0.984 18 A
    2.429 6 A
	-0.33 -1 B
	-0.97 -1 B
	0.61 -1 B
	0.69 -1 B
;
run;
data w;
	set w;
	if _ = 'A' then do;
		high = y;
		low = 0;
	end;
	if _ = 'B' then do;
		high = 0;
		low = y;
	end;
proc sgplot data = w;
	highlow x = x low = low high = high / type = bar group = _ barwidth = 0.95;
run;

I must be doing something wrong since all values of barwidth gives me the same plot. Any suggestions about what I am doing wrong ? 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @karlbang,

 

If you don't want to change the axis type: For your linear X axis the INTERVALBARWIDTH= option is applicable. Try values like 0.07in, 1.5mm, 4px, 6, etc.

View solution in original post

3 REPLIES 3
ballardw
Super User

From the HIGHLOW statement option BARWIDTH documentation:

Requirement This option is applicable only when the X or Y axis is discrete.

So you need to add an XAXIS statement setting TYPE=DISCRETE.

 


@karlbang wrote:

I am making a HIGHLOW plot

data w;
	input x y _ $;
	datalines;
    -2.460 17 A
    -0.977 12 A
    0.014 18 A
    0.984 18 A
    2.429 6 A
	-0.33 -1 B
	-0.97 -1 B
	0.61 -1 B
	0.69 -1 B
;
run;
data w;
	set w;
	if _ = 'A' then do;
		high = y;
		low = 0;
	end;
	if _ = 'B' then do;
		high = 0;
		low = y;
	end;
proc sgplot data = w;
	highlow x = x low = low high = high / type = bar group = _ barwidth = 0.95;
run;

I must be doing something wrong since all values of barwidth gives me the same plot. Any suggestions about what I am doing wrong ? 


 

FreelanceReinh
Jade | Level 19

Hello @karlbang,

 

If you don't want to change the axis type: For your linear X axis the INTERVALBARWIDTH= option is applicable. Try values like 0.07in, 1.5mm, 4px, 6, etc.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 3 replies
  • 734 views
  • 6 likes
  • 3 in conversation