BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bbauer0
Calcite | Level 5

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

1 REPLY 1
Reeza
Super User

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!

 


 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1 reply
  • 427 views
  • 0 likes
  • 2 in conversation