New Contributor
Posts: 2

# Differance between average of Class1 and the average of Class2

I have an excel file with notes of all students from Class1 and Class2.

And I want to find if there is a differance between average of Class1 and the average of Class2 students using SAS9.3?

Posts: 5,529

## Re: Differance between average of Class1 and the average of Class2

Two steps:

1. Organize your data in two columns (class, mark), each observation gives the class (1 or 2) and mark of a student.
2. Call proc ttest (after reading the documentation, of course  )
``````proc ttest data=myData;
class class;
var mark;
run;``````
PG
SAS Employee
Posts: 24

## Re: Differance between average of Class1 and the average of Class2

First you will need to read in your excel file. Take a look at the following examples if you have SAS/ACCESS to PC File Formats:

33486 - Getting Your Data into SAS

see Section 2.17

If you are not licensed for SAS/ACCESS to PC File Formats you can use DDE(Dynamic Data Exchange) to read from excel into SAS:

26146 - Write, save, close, open and read Excel files using DDE

http://support.microsoft.com/kb/128185/en-us

Or create a csv(comma separated variable) file from excel and read it in as illustrated in example 2 of the following SAS Note:

24656 - Use PROC IMPORT to read a CSV, TAB or delimited file

http://support.sas.com/techsup/notes/v8/24656

Next you will need to get your data into a form as PGStats described, have a variable for each class that represents the grade, say c1 and c2.

There are a number of approaches you can take to determine if the averages of the variables are different...proc ttest, proc means, data step. Here is the data step approach:

``````data grades;
input c1 c2;
cards;
100 99
95 100
87 100
94 80
91 89
;;;;
data average;
c1tot+c1;
c2tot+c2;
if end then do;
c1aver=round(c1tot/nobs,.1);
c2aver=round(c2tot/nobs,.1);
if c1aver=c2aver then same='Y';
else same='N';
output;
end;
keep c1aver c2aver same;
run;``````
Discussion stats
• 2 replies
• 286 views
• 0 likes
• 3 in conversation