BookmarkSubscribeRSS Feed
sejiki7
Calcite | Level 5

I have generated a graph used SGPLOT in SAS Studio, university edition, using the code below.

proc sgplot data=TABLE1;
	VBAR region;
	title 'Attacks by Region';
	footnote1 BOLD 'Codes';
	footnote3 'Region: MENA-Middle East/North Africa, WEUR-Western Europe, EEUR-Eastern Europe, NAME-North America, ASIA-Asia, OCEA-Oceana, SSAF-Sub Saharan Africa';
run;

While this works, the graph is difficult to read because one of the bars is so much larger than the others, which blows up the scale. Is there a way to add value labels and/or a grid to the plot?

2 REPLIES 2
FloT
Fluorite | Level 6

Hi,

 

This should display the labels:

proc sgplot data=TABLE1;
	VBAR region / datalabel = <your variable containing labels>;
	title 'Attacks by Region';
	footnote1 BOLD 'Codes';
	footnote3 'Region: MENA-Middle East/North Africa, WEUR-Western Europe, EEUR-Eastern Europe, NAME-North America, ASIA-Asia, OCEA-Oceana, SSAF-Sub Saharan Africa';
run;

I hope this helps,

FloT

Reeza
Super User

You could also consider a split axis.

 

http://support.sas.com/kb/55/683.html

 

data new;
   input Type $1 Value;
   datalines;
A 10
B 15
C 12
D 17
E 205
F 225
;
run;

proc sgplot data=new;
   vbar type / response=value;
   yaxis ranges=(0-20 200-230);
run;

fusion_55683_1_brokenaxis

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
  • 2 replies
  • 2235 views
  • 2 likes
  • 3 in conversation