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

Suppose i have the following sample dataset:

Group   Variable   Value

A           z                  2

A           x                  1

A           y                  3

B           z                  5

B           x                  2

B           y                  8

C          z                   3

C          x                   4

C          y                   5

 

I'm using PROC SGPANEL to produce a graph for the above data:

proc sgpanel data = data1 noautolegend;
panelby Group / onepanel layout= columnlattice novarname border;
vbar Variable/ group= Group groupdisplay=cluster groupOrder = data response= Value ;
rowaxis label = 'Change(%)';
colaxis label = ' ';
run;

In the result, for each group, the default arrangement of 'Variable' is in ascending order i.e. no matter how it is in the data. In the graph, 'Variable' is shown with x,y followed by z. But i need it exactly the way mentioned in the above example i.e. z, followed by x, and then followed by y.

I'm using the latest version of Base SAS 9.4

1 ACCEPTED SOLUTION

Accepted Solutions
hoswee
SAS Employee

If your data is in the desired order, you can update your rowaxis statement to: 

 

rowaxis label = 'Change(%)' discreteorder=data;

View solution in original post

4 REPLIES 4
hoswee
SAS Employee

If your data is in the desired order, you can update your rowaxis statement to: 

 

rowaxis label = 'Change(%)' discreteorder=data;
sayandesarkar
Calcite | Level 5
This worked. Now i want to arrange the 'Group' variable by B, followed by A, followed by C. I tried the above statement with 'colaxis'. It didn't work. How do i make this change?
DanH_sas
SAS Super FREQ

Use GROUPORDER=DATA on the VBAR statement to keep the group order.

ballardw
Super User

To control axis appearance look at axis options:

See if this works for you

colaxis label = ' ' values=( 'z' 'x' 'y');

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
  • 639 views
  • 1 like
  • 4 in conversation