BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
js5
Pyrite | Level 9 js5
Pyrite | Level 9

Hello,

 

I am trying to create a bargraph in which a scatter plot is overlaid with a bar graph. The bar graph is supposed to represent the geometric mean, and the error bars the lower and upper confidence limits of the mean. I used scatter and vbarparm statemens to achieve that, together with a dataset with precomputed values stacked under the raw dataset.

Unfortunately, the vbarparm does not seem to like having datalabel together with limitlower and limitupper, I am getting the following error (not sure where German is coming from, other messages are in English):

 

Spoiler
NOTE: Die Option DATALABEL= wird im Fehlerbalken nicht unterstützt. Das Etikett wird nicht erstellt.

This is odd as the documentation indirectly implies that the options are compatible:

If you also specify LIMITLOWER or LIMITUPPER, then the limit labels are also shown. Prior to SAS 9.4M5, limit labels are shown when you use DATALABEL or DATALABEL=variable with the limit options. Starting with SAS 9.4M5, limit labels are shown only when you use DATALABEL (without a variable).

Here is the example code:

proc summary data=sashelp.cars noprint nway;
	var msrp;
	class Origin Make;
	output out=cars_summary mean= uclm= lclm= /autoname;
run;

data for_plot;
	set sashelp.cars cars_summary;
run;

proc sgpanel data=for_plot;
	panelby Origin /layout=columnlattice;
	vbarparm category=Make response=MSRP_Mean / datalabel limitlower=MSRP_LCLM limitupper=MSRP_UCLM;
	scatter x=Make y=MSRP/ jitter;
run;

Is this supposed to work? If not, how can I overlay the geometric mean values on top of the panel?

1 ACCEPTED SOLUTION

Accepted Solutions
js5
Pyrite | Level 9 js5
Pyrite | Level 9

It is even simpler, thank you for pointing me towards highlow:

proc summary data=sashelp.cars noprint nway;
	var msrp;
	class Origin Type;
	output out=cars_summary mean= uclm= lclm= /autoname;
run;

data for_plot;
	set sashelp.cars cars_summary;
run;

proc sgpanel data=for_plot;
	panelby Origin /layout=columnlattice;
	vbarparm category=Type response=MSRP_Mean / datalabel;
	scatter x=Type y=MSRP/ jitter;
	highlow x=Type low=MSRP_LCLM high=MSRP_UCLM;
run;

View solution in original post

4 REPLIES 4
Ksharp
Super User

You want this ?

 

proc summary data=sashelp.cars noprint nway;
	var msrp;
	class Origin type;
	output out=cars_summary mean= uclm= lclm= /autoname;
run;

data for_plot;
	set sashelp.cars cars_summary;
run;

proc sgpanel data=for_plot;
	panelby Origin /layout=columnlattice;
	vbarparm category=type response=MSRP_Mean /name='a';
	scatter x=type y=MSRP/ jitter name='b';
	highlow x=type low=MSRP_LCLM high=MSRP_UCLM /LOWLABEL=MSRP_LCLM HIGHLABEL=MSRP_UCLM
HIGHCAP=SERIF LOWCAP=SERIF LINEATTRS=(color=red) LABELATTRS=(color=red);
keylegend  'a' 'b';
run;

Ksharp_0-1666616875737.png

 

js5
Pyrite | Level 9 js5
Pyrite | Level 9

I want the label to show the (geometric) mean, not the confidence limits.

Ksharp
Super User

Why not calculate it and plot it ?

 

proc summary data=sashelp.cars noprint nway;
	var msrp;
	class Origin type;
	output out=cars_summary mean= uclm= lclm= /autoname;
run;
proc univariate data=sashelp.cars noprint outtable=cars_summary2(keep=Origin type _GEOMEAN_);
	var msrp;
	class Origin type;
run;

data for_plot;
	set sashelp.cars cars_summary cars_summary2;
	if type=:'S';
run;

proc sgpanel data=for_plot;
	panelby Origin /layout=columnlattice;
	vbarparm category=type response=MSRP_Mean ;
	scatter x=type y=MSRP/ jitter transparency=0.8;
	scatter x=type y=_GEOMEAN_/markerattrs=(symbol=circlefilled color=red) datalabel=_GEOMEAN_;
run;

Ksharp_0-1666618210967.png

 

js5
Pyrite | Level 9 js5
Pyrite | Level 9

It is even simpler, thank you for pointing me towards highlow:

proc summary data=sashelp.cars noprint nway;
	var msrp;
	class Origin Type;
	output out=cars_summary mean= uclm= lclm= /autoname;
run;

data for_plot;
	set sashelp.cars cars_summary;
run;

proc sgpanel data=for_plot;
	panelby Origin /layout=columnlattice;
	vbarparm category=Type response=MSRP_Mean / datalabel;
	scatter x=Type y=MSRP/ jitter;
	highlow x=Type low=MSRP_LCLM high=MSRP_UCLM;
run;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 242 views
  • 0 likes
  • 2 in conversation