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.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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