New Contributor
Posts: 4

# How to divide two variables and compare the mean of different groups?

[ Edited ]

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.2 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
Regular Contributor
Posts: 213

## Re: How to divide two variables (with replications) and compare the means?

Please post the expected output and post the data you have as data-step.

Proc summary can create mean-values for each group.
New Contributor
Posts: 4

## Re: How to divide two variables (with replications) and compare the means?

[ Edited ]

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;``````
Regular Contributor
Posts: 213

## Re: How to divide two variables (with replications) and compare the means?

Never used proc glm, but maybe removing the class statement solves the problem.

New Contributor
Posts: 4