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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1046 views
  • 2 likes
  • 4 in conversation