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

Hello everyone!
I have a longitudinal data base and I created one graphics using the Lsmeans of Proc Glimmix (using the Enterprise guide).
However, the axis "x" didn't result in a correct order (Firstly the SAS got the output 'D10' folling 'D7', 'D8' and 'D9')
However, I am trying to organize the axes "x" in a respective order: 'D7', 'D8', 'D9', and 'D10'.
How can I do that?
I will be really grateful if someone could help-me!!!
Best regards,
Rodolfo Mingoti.
 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

That is the order character data will sort. Character sorting goes character by character left to right. And since "1" is less than "2", "3" or other character digits except "0"m "10" comes before "2".

 

Since the graphics options in most of the analysis procedures have limited appearance control options your have limited choices. One is creating a variable that will sort as required. The other is to export the data to a data set and plot with a procedure like SGPLOT where you have options to control and axis with the XAXIS statement such as a value list where you can explicitly order variable.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

Please do not post Excel files (unless your problem lies in importing those).

Use the macro provided in https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... to create a data step from your dataset, and post the resulting code here as advised in https://communities.sas.com/t5/help/faqpage/faq-category-id/posting#posting.

 

Are you sure your post should stay in Enterprise Guide, or should I move it to the SAS Statistical Procedures forum?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, it is sorting the text items.  Simplest way of getting round this is to create a format:

proc format;
  value days
    1="D1"
    2="D2"
    ...
    10="D10";
run;
data yourdata;
  set yourdata;
  format xaxisvariable days.;
run;

So I don't know your data as not opening an excel file, but I assume you have a variable which is used on the Xaxis, make this a number, with just the number of the day, e.g. 1, 2 etc.  Then apply the format which will display the data as D1, D2 etc.  This way the data will sort correctly on the Xaxis and display per the format.

ballardw
Super User

That is the order character data will sort. Character sorting goes character by character left to right. And since "1" is less than "2", "3" or other character digits except "0"m "10" comes before "2".

 

Since the graphics options in most of the analysis procedures have limited appearance control options your have limited choices. One is creating a variable that will sort as required. The other is to export the data to a data set and plot with a procedure like SGPLOT where you have options to control and axis with the XAXIS statement such as a value list where you can explicitly order variable.

Rodolfo_Mingoti
Fluorite | Level 6
Thanks ballardw, the problem has been solved!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 2066 views
  • 2 likes
  • 4 in conversation