BookmarkSubscribeRSS Feed
Ariel_1
Fluorite | Level 6

I am trying to plot a vertical barplot that will have a Percentage in the y column (from 0 -100)

 

On the Horizontal Axis i want the labels to come from two separate columns.  Does anyone have a recommendation

 

The data looks like this

 

Category          sub-Categorical                          %

A                      1                                     50

A                      2                                     45

A                      3                                     40

B                      4                                    10

B                      5                                     25

B                      6                                    30

c                      7                                    10

c                      8                                     25

c                      9                                    30

c                      10                                  30     

1 REPLY 1
ballardw
Super User

One way:

data    have;
input Category  $        subCat  $   percent;
datalines;
A        1    50
A        2    45
A        3    40
B        4    10
B        5    25
B        6    30
c        7    10
c        8    25
c        9    30
c        10   30     
;
run;

proc sgplot data=have;
   vbar category/ response=percent group=subcat groupdisplay=cluster;
   yaxis label='Percent';
run;

or

proc sgpanel data=have;
  panelby category / layout=columnlattice novarname noborder colheaderpos=bottom;
  vbar subcat / response=percent  ;
  rowaxis grid;
run;

 

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 389 views
  • 0 likes
  • 2 in conversation