BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rmacarthur
Quartz | Level 8

Hi SAS Friends,

I have a bar chart where, for clarity, would like to decrease the relative Bar length (figure), and increase the Tick area (tick) that contains survey questions.  Would also like to change the color of the bars to dark blue.

Attached is the current output (PDF) and complete code.

Am using very helpful code from this blog, 

https://blogs.sas.com/content/graphicallyspeaking/2013/12/19/survey-charts/

which indicates the tick:figure ratio is fixed at 40%.  Can this be altered?

Would like to increase the tick area to at least 60%, because that is where the message is, in the text.  Or in some other way make it easier to read the Tick (Y-Axis) text.

Any suggestions are greatly appreciated, 

Thank you !

R

	/*--Survey Data--*/
	data survey;
	  length question $ 70;
	  input response question $8-70;
	  format response percent5.1;
	  datalines;
	0.839  Developed frog prioritization protocols to manage shortages
	0.984  Experienced disruptions due to Yogurt 
	0.915  Experienced STP shortages
	0.660  Experienced frog shortages
	0.308  Disrupted assurunity-based fractionation practice
	0.154  Disrupted assurunity-based diakinetic services
	0.840  Research yarnoacists supported Yogurt  projects
	0.793  New suppliers brought in
	0.733  Increased in-house frog inventories 
	;
	run;
	proc sort	;	by descending response 	;	run	;


	%let gpath="&Gph";
	%let dpi=200;
	ods html close;
	ods listing gpath=&gpath image_dpi=&dpi;

	proc template;
	  define statgraph Survey_GTL;
	    begingraph;
	      entrytitle 'ABCD Assurunity Survey Results';
	      layout overlay / xaxisopts=(display=(ticks tickvalues) tickvalueattrs=(size=8))
	                       yaxisopts=(reverse=true display=(ticks tickvalues) 
	                       tickvalueattrs=(size=7) discreteopts=(tickvaluefitpolicy=split));
		    barchart category=question response=response / orient=horizontal 
	                 fillattrs=graphdata2 dataskin=gloss barlabel=true;
		  endlayout;
		endgraph;
	  end;
	run;

	/*--GTL HBar with default split width--*/
	%let datetime 	= 	%sysfunc(compress(%sysfunc(today(),yymmddN8.)_%sysfunc(time(),hhmm6.), ': '));
	ods graphics / reset width=6in height=5in imagename="Survey_TEST_&datetime";
	proc sgrender data=survey template=Survey_GTL;
	run;

   

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

I would recommend using Proc SGplot, rather than Proc SGrender and a custom template.

 

Something like this:

 

title1 color=gray33 "ABCD Assurunity Survey Results";
proc sgplot data=survey noborder;
hbarparm category=question response=response / datalabel fillattrs=(color=dodgerblue);
yaxis display=(nolabel noticks);
run;

 

blue_bar.png

 

View solution in original post

4 REPLIES 4
GraphGuy
Meteorite | Level 14

I would recommend using Proc SGplot, rather than Proc SGrender and a custom template.

 

Something like this:

 

title1 color=gray33 "ABCD Assurunity Survey Results";
proc sgplot data=survey noborder;
hbarparm category=question response=response / datalabel fillattrs=(color=dodgerblue);
yaxis display=(nolabel noticks);
run;

 

blue_bar.png

 

rmacarthur
Quartz | Level 8

Thank you Robert, much appreciated !

t75wez1
Quartz | Level 8

Rob,

I like your simple solution using HBARPARM statement in proc sgplot.

 

We can use the HBAR statement with the CATEGORYORDER=RESPDESC which creates the chart with the descending order of the bars.

 

But how to create a bar chart using HBARPARM statement with descending response if my response variable is not pre-sorted?

 

Thanks,

Ethan

 

GraphGuy
Meteorite | Level 14

As I understand it, sgplot's "hbar" is designed to summarize multiple obsns per bar ... and therefore you can't really sort the data ahead of time ... and therefore hbar has options to let you specify the order for it to apply to the bars after the statistic is calculated. Sgplot's "hbarparm" on the other hand, is designed to be used with pre-summarized data ... and with pre-summarized data you can simply sort the dataset before running proc sgplot. (I haven't delved into this distinction too much, and users more savvy in this area might provide additional insight/corrections/clarifications to what I said - that would not hurt my feelings!) 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 572 views
  • 1 like
  • 3 in conversation