x-axis doesn't order properly in gplot.Any Suggestions

Reply
Occasional Contributor
Posts: 14

x-axis doesn't order properly in gplot.Any Suggestions

proc gplot data=shareef.tra_pt_1m1;

plot mean_*day;

symbol value= star interpol=sm45;

run;

quit;

my x-axis values arein order in the columneg 3,7,15,30,90,180,360,720.

However in the plot i see it as

15,180,3,30,360,7,720

Thanks for help.

Regards

Mohammed Shareef

Super User
Super User
Posts: 7,411

Re: x-axis doesn't order properly in gplot.Any Suggestions

Perhaps sort the input data, I know that sometimes the order is implied from the appearance in the data.  Alternatively, and my suggestion, move over to sgplot or GTL (these are the most up to date, and offer a great welth of customization), and explicitly specify all your axis.  You can find examples at: http://blogs.sas.com/content/graphicallyspeaking/

Respected Advisor
Posts: 3,777

Re: x-axis doesn't order properly in gplot.Any Suggestions

DAY must be character as this example demonstrates.

data mean;
   infile cards dsd;
  
input nday @@;
   day = put(nday,f8.-l);
   mean = ranuni(3);
   cards;
3,7,15,30,90,180,360,720
;;;;
   run;
proc gplot;
  
plot mean*day;
   plot mean*nday;
   run;
SAS Employee
Posts: 967

Re: x-axis doesn't order properly in gplot.Any Suggestions

As data_null points out, your day values appear to be character, and the axis is therefore sorting alphabetically (rather than numerically). You could use 'proc contents' to verify that. You could add a numeric version of 'day' to your dataset (or add it in a temporary dataset), as follows...

data plot_data; set shareef.tra_pt_1m1;

day_numeric=.; day_numeric=day;

run;

proc gplot data=plot_data;

plot mean_*day_numeric;

symbol value= star interpol=sm45;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 214 views
  • 0 likes
  • 4 in conversation