In: Statistics and Probability
What are some of the codes in SAS to conduct F tests, t tests, chi squared, etc.?
For f –Test
We use the following code to run the f _test
data class;
infile 'c:\prodata2.txt'expandtabs;
input y x1 x2 x3 x4 ;
proc means data=class;
var y x1 x2 x3 x4;
run;
proc reg;
model y=x1 x2 x3 x4/spec acov;
run;
proc reg;
model y=x1 x3/spec acov;
run;
Chi-Square Test for Goodness of Fit (One Sample Test of Proportions)
The SAS code used to examine whether the two or more proportions of single categorical variables fit in the specified set of values
proc freq data=datasetname;
tables catvar / chisq testp=(p1 p2 p3…);
run;
Chi-Square Tests for Equality of Two Proportions or Association of Two Categorical Variables
the equality of two proportions or the association between two categorical variables exists, we
use a chi-square test. Chi-square tests are performed using the following SAS codes
proc freq data=datasetname;
tables catvarrow*catvarcol / chisq measures
plots=(freqplot(twoway=groupvertical scale=percent));
run;
For t-test
One sample T-test
If there is a single group (i.e. the entire sample) and you want to test whether the sample mean of a continuous variable, contvar, is different from a particular null value, h0=nullvalue, a one-sample t-test is performed in SAS
proc ttest data=datasetname h0=nullvalue plots=summary;
var contvar;
run;
Two sample T-test
If you are interested in testing whether the mean of the continuous variable, contvar, is different for a categorical variable having only two groups, catvar, then a two-sample t-test is performed.
proc ttest data=datasetname plots=summary;
class catvar;
var contvar1 contvar2 contvar3;
run;