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-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!

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
  • 291 views
  • 0 likes
  • 2 in conversation