The sample SAS program codes for basic statistics given below would compute the mean, median, variance, standard deviation, stem-and-leaf plot, box plot, and normal probability plot for each given variable.
A given dataset is use as an example.
*****
dm log 'clear';
dm output 'clear';
data Example;
input ID X1 X2 X3 X4;
datalines;
1 16 27 32 35
2 19 10 35 38
3 17 28 33 36
4 18 22 31 33
5 22 18 34 38
;
proc univariate data=Example plot;
var X1-X4 ;
title 'Summary Statistics';
run;
quit;
2. Correlation coefficients between each pair of the variables can be obtained by using the following procedure:
proc corr data=Example;
var X1-X4 ;
title2 'Correlation Coefficients';
run;
quit;
3. Three-dimension and two-dimension scatter plots of the data can be obtained by using the following procedures:
dm log 'clear';
dm output 'clear';
data Ex;
input ID X1 X2 X3;
datalines;
1 27 32 35
2 10 35 38
3 28 33 36
4 22 31 43
5 29 38 34
6 14 39 41
7 25 36 37
8 23 30 39
;
proc g3d data=Ex;
scatter x1*x2=x3;
title '3-D scatter plot';
run;
proc gplot data=Ex;
plot x2*x1;
plot x3*x1;
plot x3*x2;
title '2-D scatter plot';
run;
quit;
3-D and 2-D scatter plots can be used to display the data.
The 2-D scatter plot can be used to check the correlation between two variables. An apparent trend of the 2-D scatter plot indicates a strong correlation between two variables.
*****
Thanks to SDSU Math Department.
0 Comments:
<< Home