03-01-2017 04:07 AM
I've previously asked a question about adding significance stars to my proc sgplot. That's working now, however I also need to use a log scale. I'm getting the same note I've seen a lot around these SAS forums, Log axis cannot support zero or negative values in the data range. I don't have any zero or negative values in my data, so I don't understand where this note is coming from. I've seen the warnings about using a log scale in bar charts, however my client is insisting (the difference in concentrations between the two endpoints is huge). This is my code, do you have an idea how to solve this?
PROC SGPLOT DATA=werk10;
VBARPARM CATEGORY=group RESPONSE=gm/ GROUP=type
SCATTER x=group y=upper3/ DATALABEL=label DATALABELATTRS=(SIZE=18)
MARKERATTRS=(COLOR=white SIZE=1) LEGENDLABEL=" ";
YAXIS LABEL="Geometric mean (AU/mL)" MIN=10 MAX=400000
TYPE=LOG LOGSTYLE=LOGEXPAND LOGBASE=10;
KEYLEGEND / TITLE="Groups";
I'm still using SAS version 9.3, group is the variable for treatment group and type the variable for my endpoints.
03-01-2017 04:43 AM
Test data (in the form of a datastep)? We won't be able to see what is happening on your machine unless you show us some test data which causes this - likely to round a value which isn't 0 to 0 or something. Also, don't code in captials, it makes reading the code so much harder.
03-01-2017 05:35 AM
The VBARPARM statement is trying to draw the bars from 0 to the gm for each value of GROUP and TYPE. This is impossible on a log axis because the bars would have to be infinitely long.
The solution is the use the BASELINE= option, which was introduced in SAS 9.4m1. However, you can only specify the baseline for "freestanding" bars. Your code indicates you are using a stacked bar chart, which assumes that the baseline is 0. Switch to GROUPDISPLAY=CLUSTER and you will be able to display the bar chart on the log scale, as follows:
data A; input cat type y; datalines; 0 0 100 0 1 1000 1 0 500 1 1 30000 ; PROC SGPLOT DATA=A; VBARPARM CATEGORY=cat RESPONSE=Y/ GROUP=type baseline=10 groupdisplay=cluster; XAXIS DISCRETEORDER=DATA; YAXIS LABEL="Geometric mean (AU/mL)" MIN=10 MAX=40000 TYPE=LOG LOGSTYLE=LOGEXPAND LOGBASE=10; KEYLEGEND / TITLE="Groups"; RUN;
03-01-2017 06:03 AM
Thank you for your quick responses. RW; the coding in capitals is standard in our company so I just copied it.
Rick; I've tried the groupdisplay and baseline functions before, but these doesn't seem to be working for vbparm at least in version 9.3 (I'm getting a syntax error).
03-01-2017 02:58 PM
See my article on using log response axes with bar charts: http://blogs.sas.com/content/graphicallyspeaking/2012/04/25/bar-chart-with-log-response-axis/. You will need to ensure the y-axis does not have zero in it. Normally, all bar charts will start from zero, or have a zero baseline. You can set y axis min=0.1 or some small value. Also set the baseline. Note, the value you select can change the way the bar chart is displayed.
With SAS release prior to V9.40M1, you can use the HighLow bar to simulate a bar chart with a baseline different from zero as shown in the linked article
03-02-2017 08:44 AM
Thanks Sanjay. Am I correct in saying that if I use this highlow option, I can't add an upper limit bar anymore? My main struggle throughout this excersize has been trying to show the mean with CI AND have a log scale axis..
03-02-2017 09:04 AM
With SGPLOT you can often acheive the result you want by overlaying different plot types. I suggest you can use a scatter plot overlay, using its YERRORUPPER option to display the error bar. You can set the markerattrs=(size=0) to hide the marker itself.