The folowing code produces the nearly the same results but the gradlegend is completly misleading in the first graph. Can somebody please explain and suggest a solution when uing discrete variable to produce the gradlegend?
data class;
set sashelp.class;
if weight < 85 then wn=0;
else wn=1;
run;
data weightdisc;
retain id "wdisc";
length min $ 5 max $ 5;
input min $ max $ color $ altcolor $;
datalines;
0 0 Bio Bio
1 1 bro bro
;
run;
ods graphics on/width=800 px height=600 px;
proc sgplot data=class rattrmap=weightdisc;
vbar name/ response=Weight colorresponse=wn rattrid=wdisc ;
run;
data weightrange;
retain id "wrange";
length min $ 5 max $ 5;
input min $ max $ color $ altcolor $;
datalines;
0 85 Bio Bio
85 150 bro bro
;
run;
proc sgplot data=class rattrmap=weightrange;
vbar name/ response=Weight colorresponse=weight rattrid=wrange ;
run;
The first result look like this. As can be seen the gradlegend is completly wrong
Second option look like this
As can be seen the legend is logical.
The second option can not be used in all cases where you have a process in determing this.
There are solutions to the problem using attribute map instead. However that usually means using a dummy group variable for vbar and cannot be used for scatter plots.
Is your question "If I provide a poorly designed attribute map why does SAS display it as I instructed?" Your actual question is not clear.
Any tool has a learning curve. You have learned that the first approach may not be idea for your purpose and not to use it.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.