I am trying to produce a scatter plot where the y-axis is ordered in ascending order instead of formatted values. I have sorted the data and used :
yaxis grid discreteorder=data;
But it makes no difference. I see there is a technical report (problem note 31189) on this for dot plots and the work around suggested uses the SCATTER statement in PROC SGPLOT . However I am already using scatter. I tried running the two pieces of code on the technical support page and got the same results with both.
I tried that- it makes no difference. I also tried running both bits of suggested code in the fix on the SAS support pages (i.e. for problem note 31189) and got the same output both times.
Here is some data and the code I am using. It is a plot of estimates with CIs for several variables (identified by CNO). I wanted the plot to order cno by ratio rather than numeric order of cno.
data aplot;
input cno ratiolowercl ratioestimate ratiouppercl;
datalines;
10 0.55541 2.05934 7.63559
8 0.45885 1.31806 3.78619
6 0.33371 1.04236 3.25585
9 0.23368 0.81469 2.84031
13 0.39450 0.80129 1.62756
3 0.19638 0.78082 3.10455
12 0.08985 0.72433 5.83897
2 0.35373 0.65671 1.21921
5 0.29766 0.65028 1.42060
4 0.25529 0.63470 1.57801
7 0.07987 0.33106 1.37215
run;
proc sort data=aplot;
by descending ratioestimate;
run;
proc sgplot data=aplot;
yaxis grid type=discrete discreteorder=data;
xaxis type=log logbase=10;
scatter y=cno x=ratioestimate /xerrorlower=ratiolowercl xerrorupper=ratiouppercl ;
refline 1/axis=x label='Ratio=1';
run;
I have just discovered that if I use a character variable instead of CNO (numeric) it works correctly. Before I was assigning a character format to the numeric variable CNO.
The solution is to create a second CNO column that is character and use that column for the Y variable. The ODS Graphics system is forcing the numeric values into ascending order. Making them character get around this. The DISCRETEORDER=DATA option currently works with only bar charts, line charts, dot plots, and box plot plots, so you can remove it for this example.