BookmarkSubscribeRSS Feed
josuerodrigues
Calcite | Level 5

Hello.

I have tried so much to insert the letter of significant differences above each "stderr bar" in my graph, such as "a, b, c, d and e", but I don't know how to do it. My code is below.

 

data teste;
input source$ rep Carbon;
cards;
Controle 1 10.1
Controle 2 10.63
Controle 3 10.34
Controle 4 11.51
Controle 5 12.4
0 1 9.63
0 2 12.63
0 3 10.28
0 4 10.93
0 5 10.63
100 1 10.46
100 2 11.87
100 3 9.28
100 4 14.8
100 5 13.04
200 1 13.34
200 2 12.04
200 3 9.81
200 4 9.99
200 5 13.86
300 1 11.22
300 2 12.63
300 3 14.86
300 4 17.92
300 5 15.69
;

proc sgplot data=teste noautolegend noborder;
vbar source / response=carbon stat=mean limitstat=stderr limitattrs=(color=black) fillattrs=(color=VIGB) outlineattrs=(color="black") datalabel datalabelattrs=(color=black size=10 family="Times New Roman") fillattrs=(color=VIGB) outlineattrs=(color="black") ;
yaxis label="Soil carbon" LABELATTRS=(Color=black Family="Times New Roman" Size=12) valueattrs=(Color=black Family="Times New Roman" Size=10);
xaxis label="Source of nutrient" LABELATTRS=(Color=black Family="Times New Roman" Size=12) valueattrs=(Color=black Family="Times New Roman" Size=10);
run;

11 REPLIES 11
ballardw
Super User

I don't see any rule that tells us what value(s) should get an 'a', 'b', etc.

Kind of an import bit don't you think.

Which bar should have a label of 'a'. Why? We need this information for each of your "a, b, c, d and e".

If anything would mean that 2 or more letters are placed on one bar we need that information as well.

 


@josuerodrigues wrote:

Hello.

I have tried so much to insert the letter of significant differences above each "stderr bar" in my graph, such as "a, b, c, d and e", but I don't know how to do it. My code is below.

 

data teste;
input source$ rep Carbon;
cards;
Controle 1 10.1
Controle 2 10.63
Controle 3 10.34
Controle 4 11.51
Controle 5 12.4
0 1 9.63
0 2 12.63
0 3 10.28
0 4 10.93
0 5 10.63
100 1 10.46
100 2 11.87
100 3 9.28
100 4 14.8
100 5 13.04
200 1 13.34
200 2 12.04
200 3 9.81
200 4 9.99
200 5 13.86
300 1 11.22
300 2 12.63
300 3 14.86
300 4 17.92
300 5 15.69
;

proc sgplot data=teste noautolegend noborder;
vbar source / response=carbon stat=mean limitstat=stderr limitattrs=(color=black) fillattrs=(color=VIGB) outlineattrs=(color="black") datalabel datalabelattrs=(color=black size=10 family="Times New Roman") fillattrs=(color=VIGB) outlineattrs=(color="black") ;
yaxis label="Soil carbon" LABELATTRS=(Color=black Family="Times New Roman" Size=12) valueattrs=(Color=black Family="Times New Roman" Size=10);
xaxis label="Source of nutrient" LABELATTRS=(Color=black Family="Times New Roman" Size=12) valueattrs=(Color=black Family="Times New Roman" Size=10);
run;


 

josuerodrigues
Calcite | Level 5

if you run my code, you will see one graph with five bars. So I want to know how I can put some letters above them. For example, "a, b, c, d and e" above each stderr bar. Do you understand? 

josuerodrigues_0-1722470205317.png

 

ballardw
Super User

@josuerodrigues wrote:

if you run my code, you will see one graph with five bars. So I want to know how I can put some letters above them. For example, "a, b, c, d and e" above each stderr bar. Do you understand? 

josuerodrigues_0-1722470205317.png

 


Not really. There are no values of 'a' 'b' etc. in the data, so you have to tell us where those come from. And which bar they would go to. Depending on where the value comes from you likely need to modify the plot data set and possibly even completely change the type of graph.

josuerodrigues
Calcite | Level 5

The letters came from the Tukey test, meaning that group 0 is different from group 100, etc., so the letters help us understand which group is greater. For example, I want to put the "letter a" above stderr bar of group 300. How can I do that? If I have to modify my dataset, how can I do that? Do you understand my doubt? 

ballardw
Super User

@josuerodrigues wrote:

The letters came from the Tukey test, meaning that group 0 is different from group 100, etc., so the letters help us understand which group is greater. For example, I want to put the "letter a" above stderr bar of group 300. How can I do that? If I have to modify my dataset, how can I do that? Do you understand my doubt? 


Where is the code that does the Tukey test? Where are the results stored? How do we know that "letter a" appears above group 300 instead of above group 100 or any other group.

You need to provide the rules.

OR if this a manual step then you have provide enough information somehow for use to show ways to provide that link. Rules are needed to write programs. Examples are insufficient to create workable programs.

josuerodrigues
Calcite | Level 5

Ok, I ran another code with Tukey test. You can see it below. According to my statistics, I want to put the letter 'a in group 300', 'ab in groups 100, 200 and control' and put the letter 'c in group 0'. I want to do a graph like that (second graph).

 

data teste;
input source$ rep Carbon;
cards;
Controle 1 10.1
Controle 2 10.63
Controle 3 10.34
Controle 4 11.51
Controle 5 12.4
0 1 9.63
0 2 12.63
0 3 10.28
0 4 10.93
0 5 10.63
100 1 10.46
100 2 11.87
100 3 9.28
100 4 14.8
100 5 13.04
200 1 13.34
200 2 12.04
200 3 9.81
200 4 9.99
200 5 13.86
300 1 11.22
300 2 12.63
300 3 14.86
300 4 17.92
300 5 15.69
;
proc glm data=teste plots=diagnostics;
class source;
model carbon = source;
means source / hovtest=levene(type=abs) tukey;
run;

proc sgplot data=teste noautolegend noborder;
vbar source / response=carbon stat=mean limitstat=stderr limitattrs=(color=black) fillattrs=(color=VIGB) outlineattrs=(color="black") datalabel datalabelattrs=(color=black size=10 family="Times New Roman") fillattrs=(color=VIGB) outlineattrs=(color="black") ;
yaxis label="Soil carbon" LABELATTRS=(Color=black Family="Times New Roman" Size=12) valueattrs=(Color=black Family="Times New Roman" Size=10);
xaxis label="Source of nutrient" LABELATTRS=(Color=black Family="Times New Roman" Size=12) valueattrs=(Color=black Family="Times New Roman" Size=10);
run;

josuerodrigues_1-1723142471115.png

 

josuerodrigues_0-1723142434289.png

 

ballardw
Super User

There is still no rules in  your description of 1) how you decide that any specific value in "groups" (which are not really in your data, do you mean SOURCE?) Why does 300 get 'a', why does 100 and 200 get 'ab', 0 get 'c'?

josuerodrigues
Calcite | Level 5

I've already answered your question. The letter "a" means the group 300 is better the group 0 (letter c). Do you know some way to put some letters in my vbar? If you don't know, I will give up.

ballardw
Super User

@josuerodrigues wrote:

I've already answered your question. The letter "a" means the group 300 is better the group 0 (letter c). Do you know some way to put some letters in my vbar? If you don't know, I will give up.


@Ksharp showed how to place arbitrary text at given columns in https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-insert-the-standard-error-of-the-... 

3 weeks ago.

 

I was trying to get the rules on where the values come from so we could generate a generic approach using the results of the data. Such as adding an ODS OUTPUT to the Proc GLM code:

proc glm data=teste ;
class source;
model carbon = source;
means source / hovtest=levene(type=abs) tukey;
ods output mclines=tukeyresults (where=(not missing(level)));
run;

The data set Tukeyresults created above could be parsed to get the LEVEL values associated with the test results and provide the text values. But since the OUTPUT of that data set does not have anything with lower case 'a' or lower case 'ab' or even 'c' I was trying to get you to describe the decision process that goes into creating those values from output because I have zero understanding of why 'c' is preferable to 'Z' or any other character. A clearly stated process can be programmed (though work is involved), an arbitrary set of values cannot.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 1070 views
  • 0 likes
  • 4 in conversation