BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
gbortolami
Calcite | Level 5

Dear all,

 

I am using sgplot in sas studio for academics.

Building a very simple scatter plot (Variable 1 vs Variable 2), I am using a third variable as colorresponse.

The results is showing me the color legend for Variable 3 with a discrete tick interval excluding the highest and lowest values (see screenshot attached).

I would like to modify the tick interval in the legend in order to have the lowest (0) and the highest (0.32) values indicated, any tips?

 

Thanks a lot!

GiovanniCapture_SAS.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data rattrmap;
retain id "id";
length min $ 5 max $ 5;
input min $ max $ ALTCOLORMODEL1 $ ALTCOLORMODEL2 $  ;
datalines;
0    0.1   white    greyaa 
0.1  0.2   greyaa   grey99
0.2  0.3   grey99   grey88
0.3  1     grey88   black
;
run;

data have;
call streaminit(123);
do i=1 to 100;
 x=rand('integer',0,90);
 y=rand('integer',-30,80);
 r=rand('uniform');
 output;
end;
run;

proc sgplot data=have rattrmap=rattrmap;
scatter x=x y=y /markerattrs=(symbol=circlefilled) colormodel=(white black) colorresponse=r rattrid=id ;
run;

Ksharp_0-1705559560939.png

 

View solution in original post

3 REPLIES 3
ballardw
Super User

When asking how to modify any existing procedure you should include the current code you are using so we have some idea what you have attempted. Best is also to include some example data in the form of a working data step so we can test suggestions to see that they will actually work. Code should be pasted as text into text or code box opened on the forum with the </> or "running man" icons that appear above the main message windows. The main message boxes on this forum will reformat pasted text and may result in code that doesn't run properly when copied and run elsewhere.

Ksharp
Super User
data rattrmap;
retain id "id";
length min $ 5 max $ 5;
input min $ max $ ALTCOLORMODEL1 $ ALTCOLORMODEL2 $  ;
datalines;
0    0.1   white    greyaa 
0.1  0.2   greyaa   grey99
0.2  0.3   grey99   grey88
0.3  1     grey88   black
;
run;

data have;
call streaminit(123);
do i=1 to 100;
 x=rand('integer',0,90);
 y=rand('integer',-30,80);
 r=rand('uniform');
 output;
end;
run;

proc sgplot data=have rattrmap=rattrmap;
scatter x=x y=y /markerattrs=(symbol=circlefilled) colormodel=(white black) colorresponse=r rattrid=id ;
run;

Ksharp_0-1705559560939.png

 

gbortolami
Calcite | Level 5
Thanks a lot!!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 616 views
  • 1 like
  • 3 in conversation