First, sorry for the redundancy: I found a post written by @js5 that corresponds to my problem (proc sgpanel: is datalabel supposed to work with limitlower and limitupper?) but it is closed with no clear answer to the original question (Is DATALABEL supposed to work with LIMITLOWER and LIMITUPPER in PROC SGPANEL?) and the proposed solution does not work for me so here we go with a new post on the matter: I have a simple dataset structured as follows: data my_data_SGPANEL;
input food_group sex select_var Mean LowerCLMean UpperCLMean;
datalines;
111 1 0 6.2 5.6 6.8
111 1 1 2.7 2.1 3.3
111 2 0 4.9 4.5 5.4
111 2 1 1.5 1.0 2.0
112 1 0 2.3 2.0 2.6
112 1 1 0.9 0.6 1.1
112 2 0 2.9 2.5 3.3
112 2 1 2.4 1.3 3.4
...
;
run; I have attached the complete dataset to my post. I am on SAS 9.4M5. I would like to use a SGPANEL procedure to plot bar charts by sex side by side. I have tried using PROC SGPANEL with options DATALABEL, LIMITLOWER and LIMITUPPER to get error bars and value labels displayed on the graphs. I used option DATALABEL without a variable, as specified in SAS Documentation (here for the LIMITLOWER option). However, it looks like options DATALABEL and LIMITLOWER/LIMITUPPER are simply incompatible. When I use them together, I get this note in my LOG, twice (one for LIMITLOWER and the other for LIMITUPPER, I guess): NOTE: La barre d'erreur ne prend en charge l'option DATALABEL=. Le libellé ne sera pas ajouté. Which roughly translates to “The DATALABEL= option is not supported by the error bar. The label will not be added.” (Sorry for the poor translation but the original first French sentence is pretty bad and actually does not mean anything… Like in @js5's post, not sure where French is coming from here since all the other messages in my LOG are in English). Here is the code: /* Formats used in the graphs */
proc format;
/** Yes / No **/
value ynfmt 0 = "No" 1 = "Yes";
/** Food groups **/
value fdgpfmt 111 = "red meat" 112 = "poultry" 113 = "game" 114 = "offals" 115 = "processed meat";
run;
/* SGPANEL procedure */
proc sgpanel data = my_data_SGPANEL;
panelby sex;
vbarparm category = food_group response = Mean / group = select_var groupdisplay = cluster DataLabel LimitLower = LowerCLMean LimitUpper = UpperCLMean LimitAttrs = (Color = black);
format sex sexfmt. food_group fdgpfmt. select_var ynfmt. Mean F4.1 LowerCLMean F4.1 UpperCLMean F4.1;
ColAxis display = (NoLabel);
RowAxis label = "Percents";
run; And here is the output (error bars but no data labels): If I remove options LIMITLOWER, LIMITUPPER and LIMITATTRS from the code above, the data labels are displayed on top of the bars (and I could not find how to choose their position on the graph) but, as expected, no limit lines are displayed: I guess that one solution could be to use a SGPLOT procedure by sex: proc sort data = my_data_SGPANEL; by sex; run;
proc sgplot data = my_data_SGPANEL;
by sex;
vbarparm category = food_group response = Mean / group = select_var GroupDisplay = cluster DataLabel LimitLower = LowerCLMean LimitUpper = UpperCLMean LimitAttrs = (Color = black);
format sex sexfmt. food_group fdgpfmt. select_var ynfmt. Mean F4.1 LowerCLMean F4.1 UpperCLMean F4.1;
xAxis display = (NoLabel);
yAxis label = "Percents";
run; Using PROC SGPLOT, the output for sex = Male: Using the graphs generated by the SGPLOT procedure, I could "create" the panel through post-editing. However, it would be better if I could get SAS to do this panel directly to avoid going through post-editing. So Is DATALABEL supposed to work with LIMITLOWER and LIMITUPPER when using PROC SGPANEL? If so, how should I proceed? Any suggestions? 🙂
... View more