12-20-2016 05:33 AM
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.
12-20-2016 09:55 AM
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.