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

I'm trying to use PROC SGPLOT to plot means w/ SE bars, per this code (Sample 42542: Plot means with standard error bars from calculated data with PROC SGPLOT).

 

How can I add a grouping variable so that there will be a line for each level of the group (e.g. Treatment and control)?

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

It sounds like you have two BY variables. So for the calculations make sure to specify the two BY variables.

 

For SGPLOT try the GROUP= GROUP_VAR on the scatter statement. 

 

Check the doc for the SCATTER statement for more details.

View solution in original post

2 REPLIES 2
Reeza
Super User

It sounds like you have two BY variables. So for the calculations make sure to specify the two BY variables.

 

For SGPLOT try the GROUP= GROUP_VAR on the scatter statement. 

 

Check the doc for the SCATTER statement for more details.

Ksharp
Super User

Use GROUP= option . Check this out.

http://blogs.sas.com/content/graphicallyspeaking/2012/03/30/cluster-groups/

 

data have;
infile cards expandtabs truncover;
input drug $ group$ mean lcl ucl;
cards;
A Treat   10  6 14
A Placebo  8  6 10
B Treat   20  16 24
B Placebo  12  6 14
;
run;
proc sgplot data=have;
  scatter x=drug y=mean/ yerrorlower=lcl yerrorupper=ucl group=group
          markerattrs=(symbol=circlefilled)
          groupdisplay=cluster clusterwidth=0.5 errorbarattrs=(thickness=1);
  series  x=drug y=mean/ lineattrs=(pattern=solid) group=group
          groupdisplay=cluster clusterwidth=0.5 lineattrs=(pattern=dash thickness=2)
           name='s';
  yaxis label='Mean with 95% CL' grid;
  xaxis display=(nolabel);
  keylegend 's' / title='Treatment';
  run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 7490 views
  • 2 likes
  • 3 in conversation