Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- gplot: additing standard errors

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 07-05-2018 11:58 AM
(992 views)

Hello,

I am trying to add standard errors to my graph in gplot but unsuccessfully so far. Here is what I have: I ran repeated measures (with test as a within-subject variables [three tests] and group as a between-subject factor [3 groups]). I successfully made a graph that doesn't have standard errors using the following syntax:

```
proc glm data = dataset;
class Group;
model Test1 Test2 Test3 = Group;
repeated Test 3 /summary;
lsmeans Group / out=means adjust = T tdiff stderr;
run;
goptions reset=all;
symbol1 c=blue v= triangle h=2.5 i=j;
symbol2 c=red v=circle h=2.5 i=j;
symbol3 c=green v=square h=2.5 i=j;
axis1 label=(a=90 'Means');
axis2 label=('Test') value=('Test1' 'Test2' 'Test3');
proc gplot data = means;
plot lsmean*_name_ = Group / vaxis=axis1 haxis=axis2;
run;
quit;
```

The problem now is adding standard errors. Could anyone please help me with how to modify the syntax I have to add standard errors?

Thank you in advance.

6 REPLIES 6

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Use SGPLOT instead with a SCATTER or SERIES statement and you can easily add the error bars. Is there any particular reason to use GPLOT? It’s pretty outdated.

See XERROR and YERROR options within the Series statement.

@Amanda_Lemon wrote:

Hello,

I am trying to add standard errors to my graph in gplot but unsuccessfully so far. Here is what I have: I ran repeated measures (with test as a within-subject variables [three tests] and group as a between-subject factor [3 groups]). I successfully made a graph that doesn't have standard errors using the following syntax:

`proc glm data = dataset; class Group; model Test1 Test2 Test3 = Group; repeated Test 3 /summary; lsmeans Group / out=means adjust = T tdiff stderr; run; goptions reset=all; symbol1 c=blue v= triangle h=2.5 i=j; symbol2 c=red v=circle h=2.5 i=j; symbol3 c=green v=square h=2.5 i=j; axis1 label=(a=90 'Means'); axis2 label=('Test') value=('Test1' 'Test2' 'Test3'); proc gplot data = means; plot lsmean*_name_ = Group / vaxis=axis1 haxis=axis2; run; quit;`

The problem now is adding standard errors. Could anyone please help me with how to modify the syntax I have to add standard errors?

Thank you in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

It doesn't seem that a SERIES statement has an option to add error bars... I am reading here: http://morgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/en/grstatproc/61948/HTML/de...

A SCATTER statement has this option but I am not sure if I can connect my dots using SCATTER?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Use both a series and scatter statement then? They’ll overlay automatically.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Got it! Thank you. One more question -- is there a way to change marker or line attributes by group? So, for example, in my syntax below all markers are filled circles but I want circles for Group 1 but triangles for Group 2 and squares for Group 3. Is it possible to change?

```
proc sgplot data=means_2;
scatter x = _name_ y = lsmean / group = Group yerrorlower = lower yerrorupper = upper
```

markerattrs = (symbol = circlefilled size = 10) datalabel = lsmean_rounded;
series x = _name_ y = lsmean / group = Group lineattrs = (pattern = solid thickness = 2);
run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Data attribute maps are my preferred way. You can then make sure it aligns across both graphs even if one is missing a value or something like that.

@Amanda_Lemon wrote:

Got it! Thank you. One more question -- is there a way to change marker or line attributes by group? So, for example, in my syntax below all markers are filled circles but I want circles for Group 1 but triangles for Group 2 and squares for Group 3. Is it possible to change?

`proc sgplot data=means_2; scatter x = _name_ y = lsmean / group = Group yerrorlower = lower yerrorupper = upper`

markerattrs = (symbol = circlefilled size = 10) datalabel = lsmean_rounded; series x = _name_ y = lsmean / group = Group lineattrs = (pattern = solid thickness = 2); run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I ran into one more small problem. In the sgplot syntax above, I have datalabel option for scatter and I also have series on the same plot. The problem is my data labels overlap with my lines, and it doesn't look good (also difficult to see labels). Is there a way to get the software to place data labels in a way that they don't overlap with lines?

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

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.