How do I offset displays for mean values with standard error by group for separate time periods?

Accepted Solution Solved
Reply
Learner
Posts: 1
Accepted Solution

How do I offset displays for mean values with standard error by group for separate time periods?

Greetings,

 

I am trying to plot means of three treatments over four time periods.  I am have having trouble getting the means for each treatment to display side-by-side for each period, per the example shown here (minus the trend lines):

plot means with standard error.JPG

 

This is how my plot looks:

benthic biomass plot.JPG

My code is as follows:

DATA ccinmass;
INPUT obs $ block $ unit $ time $ trt $ cinv sinv tinv sav wg sr abund coreh
depth pen temp sal ph;
run;
proc sort;
by trt time;
run;
proc means noprint;
by trt time;
var cinv;
output out=meansout mean=mean stderr=stderr;
run;
data reshape (keep=trt time cinv mean);
set meansout;
by trt time;
cinv=mean;
output;
cinv=mean-stderr;
output;
cinv=mean+stderr;
output;
run;
title1 'Benthic Invertebrate Biomass (g[dry]/m^2) Means with Standard Error';
axis1 offset=(5,5) minor=none value=(tick=1 'August' justify=c '2016'
                                                            tick=2 'November' justify=c '2016'
                                                            tick=3 'January' justify=c '2017'
                                                            tick=4 'April' justify=c '2017');
axis2 order=(0 to 12 by 2) minor=(n=1) label=(angle=90 'Benthic Invertebrate Biomass (g[dry]/m^2)');
symbol1 interpol=hiloct color=BIB line=1;
symbol2 interpol=hiloct color=RED line=2;
symbol3 interpol=hiloct color=GREEN line=3;
symbol4 interpol=none color=BIB value=dot height=1.5;
symbol5 interpol=none color=RED value=dot height=1.5;
symbol6 interpol=none color=GREEN value=dot height=1.5;
legend1 label=('Treatment:') frame;
proc gplot data=reshape;
      plot cinv*time=trt/haxis=axis1 vaxis=axis2 legend=legend1;
      plot2 mean*time=trt/vaxis=axis2 noaxis nolegend;
run;

 

Any help would be greatly appreciated!

 


Accepted Solutions
Solution
Wednesday
Super User
Posts: 23,683

Re: How do I offset displays for mean values with standard error by group for separate time periods?

[ Edited ]

Add a bit to the time variable so one is July 31st and one is August 4th (random numbers I made up). Then explicitly set the values to show on the axis but the bars will be on either side slightly. You can also try moving to SGPLOT which has better graphical controls.

 


@bbauer0 wrote:

Greetings,

 

I am trying to plot means of three treatments over four time periods.  I am have having trouble getting the means for each treatment to display side-by-side for each period, per the example shown here (minus the trend lines):

plot means with standard error.JPG

 

This is how my plot looks:

benthic biomass plot.JPG

My code is as follows:

DATA ccinmass;
INPUT obs $ block $ unit $ time $ trt $ cinv sinv tinv sav wg sr abund coreh
depth pen temp sal ph;
run;
proc sort;
by trt time;
run;
proc means noprint;
by trt time;
var cinv;
output out=meansout mean=mean stderr=stderr;
run;
data reshape (keep=trt time cinv mean);
set meansout;
by trt time;
cinv=mean;
output;
cinv=mean-stderr;
output;
cinv=mean+stderr;
output;
run;
title1 'Benthic Invertebrate Biomass (g[dry]/m^2) Means with Standard Error';
axis1 offset=(5,5) minor=none value=(tick=1 'August' justify=c '2016'
                                                            tick=2 'November' justify=c '2016'
                                                            tick=3 'January' justify=c '2017'
                                                            tick=4 'April' justify=c '2017');
axis2 order=(0 to 12 by 2) minor=(n=1) label=(angle=90 'Benthic Invertebrate Biomass (g[dry]/m^2)');
symbol1 interpol=hiloct color=BIB line=1;
symbol2 interpol=hiloct color=RED line=2;
symbol3 interpol=hiloct color=GREEN line=3;
symbol4 interpol=none color=BIB value=dot height=1.5;
symbol5 interpol=none color=RED value=dot height=1.5;
symbol6 interpol=none color=GREEN value=dot height=1.5;
legend1 label=('Treatment:') frame;
proc gplot data=reshape;
      plot cinv*time=trt/haxis=axis1 vaxis=axis2 legend=legend1;
      plot2 mean*time=trt/vaxis=axis2 noaxis nolegend;
run;

 

Any help would be greatly appreciated!

 


 

View solution in original post


All Replies
Solution
Wednesday
Super User
Posts: 23,683

Re: How do I offset displays for mean values with standard error by group for separate time periods?

[ Edited ]

Add a bit to the time variable so one is July 31st and one is August 4th (random numbers I made up). Then explicitly set the values to show on the axis but the bars will be on either side slightly. You can also try moving to SGPLOT which has better graphical controls.

 


@bbauer0 wrote:

Greetings,

 

I am trying to plot means of three treatments over four time periods.  I am have having trouble getting the means for each treatment to display side-by-side for each period, per the example shown here (minus the trend lines):

plot means with standard error.JPG

 

This is how my plot looks:

benthic biomass plot.JPG

My code is as follows:

DATA ccinmass;
INPUT obs $ block $ unit $ time $ trt $ cinv sinv tinv sav wg sr abund coreh
depth pen temp sal ph;
run;
proc sort;
by trt time;
run;
proc means noprint;
by trt time;
var cinv;
output out=meansout mean=mean stderr=stderr;
run;
data reshape (keep=trt time cinv mean);
set meansout;
by trt time;
cinv=mean;
output;
cinv=mean-stderr;
output;
cinv=mean+stderr;
output;
run;
title1 'Benthic Invertebrate Biomass (g[dry]/m^2) Means with Standard Error';
axis1 offset=(5,5) minor=none value=(tick=1 'August' justify=c '2016'
                                                            tick=2 'November' justify=c '2016'
                                                            tick=3 'January' justify=c '2017'
                                                            tick=4 'April' justify=c '2017');
axis2 order=(0 to 12 by 2) minor=(n=1) label=(angle=90 'Benthic Invertebrate Biomass (g[dry]/m^2)');
symbol1 interpol=hiloct color=BIB line=1;
symbol2 interpol=hiloct color=RED line=2;
symbol3 interpol=hiloct color=GREEN line=3;
symbol4 interpol=none color=BIB value=dot height=1.5;
symbol5 interpol=none color=RED value=dot height=1.5;
symbol6 interpol=none color=GREEN value=dot height=1.5;
legend1 label=('Treatment:') frame;
proc gplot data=reshape;
      plot cinv*time=trt/haxis=axis1 vaxis=axis2 legend=legend1;
      plot2 mean*time=trt/vaxis=axis2 noaxis nolegend;
run;

 

Any help would be greatly appreciated!

 


 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 37 views
  • 0 likes
  • 2 in conversation