Data visualization with SAS programming

Using bloc statements on the Y-axis in scatter or hbarparm

Reply
Contributor
Posts: 62

Using bloc statements on the Y-axis in scatter or hbarparm

I would really like to use block statements on the y axis. I make a lot of plots on depth where you usually have the y-axis as your "normal" x-axis and the value on the X..

 

Vbarparm works nice

hbar.PNG

While hparparm does not work nice

vbar.PNG

 

Whenever I try to use block on the Y-axis SAS says it does not support so. Does anybody have a work around?

 

A question to SAS is why can't this be supported? 

The code for creating the graphs are below. 

 

Looking at the generated GTL templates they are equal with the exception that the horisontal has an orient = horizontal added. This tells me that it basically treats the plot the same. However you cant just use orient on the block plot.

 

Here is the code to reproduce.

proc hpbin data=sashelp.class numbin=5;
	var weight;
	ods output mapping=map;
run;

/*Add a block variable*/

data map;
	set map;
	length block $ 8;
	if bin=1 then block='Low';
	else if bin=5 then block='High';
	else block='Middle';
	/*Fixing frequencies to show problem better*/
	frequency= frequency*10;
run;
ods graphics on / heighyt=300 px width=400 px;

/*This is nice*/

proc sgplot data=map tmplout='/shared/winshare/teams_no/AnalyticalFiles/vbarparm.txt';
	vbarparm category=bin response=frequency;
	block X=bin block=block / transparency=0.9;
run;


/*This is not nice*/

proc sgplot data=map tmplout='/shared/winshare/teams_no/AnalyticalFiles/hbarparm.txt';;
	hbarparm category=bin response=frequency;
	block x=bin block=block / transparency=0.9;
	/*Block only responds to x variable*/
	
run;

 

SAS Super FREQ
Posts: 4,124

Re: Using bloc statements on the Y-axis in scatter or hbarparm

Posted in reply to PaalNavestad

I don't think PROC SGPLOT supports horizontal BLOCKs. You would have to emulate them by using the POLYGON statement or use annotation.

Contributor
Posts: 62

Re: Using bloc statements on the Y-axis in scatter or hbarparm

Thanks Rick, can you say anything about why? It seems like it is relativly easy to do as the GTL is more or less just switching axis. A band plot and a High - low with a bit of the same behaviour seem to handle this. Creating a large set of polygons is a bit cumbersome, but probably completely doable.

 

Are there any plans to add in next version?

SAS Super FREQ
Posts: 4,124

Re: Using bloc statements on the Y-axis in scatter or hbarparm

Posted in reply to PaalNavestad

No, I do not have any insight into why. Most likely the reason is that PROC SGPLOT is designed to handle the common cases that 95% of the people want 95% of the time. Until someone like you asks for a feature, the development team might not know that it is wanted by customers.

 

I would encourage you to ask for this feature if it is important to you. Like you, I have sometimes needed this feature and lamented that it was not in SGPLOT. 

Contributor
Posts: 62

Re: Using bloc statements on the Y-axis in scatter or hbarparm

OK,

I'll post it as a wish if I remember how. 

SAS Super FREQ
Posts: 1,265

Re: Using bloc statements on the Y-axis in scatter or hbarparm

Posted in reply to PaalNavestad
It is not available in GTL either. Hence, it is not available in SGPLOT. Mostly because no one (initially) asked for this use case. It would help if you put in your request for this feature with Tech Support. The "InnerMargins" needed for this plot were initially only available for x-axis. Inner Margins for Y axis were added only recently. So, now it would be easier to implement a y-axis version of this plot.
Ask a Question
Discussion stats
  • 5 replies
  • 179 views
  • 4 likes
  • 3 in conversation