BookmarkSubscribeRSS Feed
cws
Fluorite | Level 6 cws
Fluorite | Level 6
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.
8 REPLIES 8
GraphGuy
Meteorite | Level 14
Perhpas "proc gplot" will do what you're wanting(?)
DanH_sas
SAS Super FREQ
If your data is numeric, you may also need to set TYPE=DISCRETE on the YAXIS statement.

-- Dan
cws
Fluorite | Level 6 cws
Fluorite | Level 6
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.
GraphGuy
Meteorite | Level 14
Can you post up a small example (data & code)?
DanH_sas
SAS Super FREQ
Can you post the procedure code snipit? Also post the data type of your variables.

Thanks!
Dan
cws
Fluorite | Level 6 cws
Fluorite | Level 6
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.


Message was edited by: cws
DanH_sas
SAS Super FREQ
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.

Thanks!
Dan
cws
Fluorite | Level 6 cws
Fluorite | Level 6
Thanks Dan.

Got there in the end!

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 8 replies
  • 5260 views
  • 0 likes
  • 3 in conversation