Hello.
The following is the data that I want to analyze. The variables are Group, A and B. Basically, I want to find the mean of A and B in each group, divide A_mean by B_mean (= y), and compare the value of y between the groups (by Tukey for example). A and B are measured three times in all groups, except for B in Group 2. A and B are also independent. How should I write my SAS code?
Thank you.
1 | 6.57 | 3.14 |
1 | 6.77 | 3.09 |
1 | 6.71 | 3.14 |
2 | 20.27 | 9.37 |
2 | 20.27 | 10.20 |
2 | 21.82 | 10.14 |
2 | . | 10.44 |
2 | . | 9.83 |
2 | . | 9.69 |
2 | . | 9.37 |
3 | 21.35 | 10.71 |
3 | 21.34 | 10.74 |
3 | 21.63 | 10.79 |
4 | 13.40 | 6.77 |
4 | 13.10 | 6.86 |
4 | 13.87 | 6.99 |
5 | 17.29 | 8.81 |
5 | 16.83 | 8.92 |
5 | 17.26 | 8.83 |
Here's my SAS code. The problem with this code is that after dividing A_Mean by B_Mean, a single value of y for each group is obtained. As a result, I am not able to compare and test the significance of the the y's.
data data;
input Group A B;
datalines;
1 6.57 3.14
1 6.77 3.09
1 6.71 3.14
2 20.27 9.37
2 20.27 10.20
2 21.82 10.14
2 . 10.44
2 . 9.83
2 . 9.69
2 . 9.37
3 21.35 10.71
3 21.34 10.74
3 21.63 10.79
4 13.40 6.77
4 13.10 6.86
4 13.87 6.99
5 17.29 8.81
5 16.83 8.92
5 17.26 8.83
;
proc print;
run;
proc means;
class Group;
var A B;
output out=out mean= / autoname;
run;
proc print data=out;
run;
data new;
set out;
y=divide(A_Mean, B_Mean);
run;
proc print;
run;
proc glm data=new;
class Group;
model y=Group;
run;
Never used proc glm, but maybe removing the class statement solves the problem.
No, it did not help.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.