I'm using SAS 9.3. I have a dataset with several hundred readings. I am attempting to plot two variables relative to a third, using proc sgplot. The first two values, which I will call VarA and VarB, are continuous and have values between 1 and 5. The third variable, XValue, contains only integer values from 1 through 5 inclusive. I am using proc sgplot to print vertical bar charts for the frequency of each For some reason which I cannot figure out, the colors for the bar charts are different for the two plots. I've attached a file showing the output, where you can see that the color order for the plots is as follows: XValue VarA VarB 1 green green 2 blue brown 3 red blue 4 brown red 5 purple purple In other words, while the end colors are consistent, the colors for the intermediate values are not. I would like the plots to maintain consistent colors. The code I am using follows: proc format; value grpf 1 - <1.5 = "1 - 1.5" 1.5 - <2.5 = "1.5 - 2.5" 2.5 - <3.5 = "2.5 - 3.5" 3.5 - <4.5 = "3.5 - 4.5" 4.5 - 5 = "4.5 - 5"; value xvalf 1 = "Why" 2 = "are" 3 = "these" 4 = "different" 5 = "colors?"; proc sgplot data=use; title "Why is SAS changing the order of the colors for XValue?"; vbar VarA / stat=freq group=XValue grouporder=ascending groupdisplay=cluster; format VarA VarB grpf. XValue xvalf.; run; proc sgplot data=use; title "Why is SAS changing the order of the colors for XValue?"; vbar VarB / stat=freq group=XValue grouporder=ascending groupdisplay=cluster; format VarA VarB grpf. XValue xvalf.; run; And the resulting plots are: As you can see, the only difference between the two instances of proc sgplot is the variable being plotted by the vbar statement. How can I obtain consistent colors for multiple plots? This is a simplified form of the program. I have many more plots I need to run, and I need the color of XValue to be consistent across all the plots. I'd appreciate any help anyone can give me. Thanks!
... View more