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

I used the following code, but I want the columns in a different order.

ods graphics on;
proc glm plots=diagnostics;
class trt;
model pct_Juice	Brix	Acid	Ratio	BrimA =  trt;
lsmeans trt/adjust=tukey alpha=0.05 lines;
run;

Here is the default graph, but the columns are in alphabetical order. I want "Control" as the first column on the left.

Fruit1.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

In your SAS data set, add a space in front of 'Control' so it is now ' Control'

 

Then run PROC GLM again

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

In your SAS data set, add a space in front of 'Control' so it is now ' Control'

 

Then run PROC GLM again

--
Paige Miller
Reeza
Super User

Generally you have two options:

1. Make the graph using the output and SGPLOT

2. Map numbers to the values you'd like ordering them in the order you'd like to see, ie Control = 0, Black = 1, Blue = 2 and use Labels to control the displayed value. Then once they're sorted by default they'll show the labels in the order desired.

 


@tebert wrote:

I used the following code, but I want the columns in a different order.

ods graphics on;
proc glm plots=diagnostics;
class trt;
model pct_Juice	Brix	Acid	Ratio	BrimA =  trt;
lsmeans trt/adjust=tukey alpha=0.05 lines;
run;

Here is the default graph, but the columns are in alphabetical order. I want "Control" as the first column on the left.

Fruit1.jpg


 

tebert
Obsidian | Level 7
PaigeMiller gave a solution that gets me through today. I have not used SGPlot or mapping so it will take more effort to see how well I gan get these suggestions to work. This answer will be a more general solution.
Reeza
Super User
It'll only really work for Control, if you want to control the order of the other categories, ie put them descending or something else, this solution won't work. This is a very specific solution.
tebert
Obsidian | Level 7
It will work to put any one column first. I could put a space in front of "Pink" to move that to the front. I suspect I could also order others by adding multiple spaces. However, with many spaces there will be other issues so adding spaces is not a general solution. It only gets me through today.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 963 views
  • 5 likes
  • 3 in conversation