Escolar Documentos
Profissional Documentos
Cultura Documentos
3) Read from a file add the following after naming your data set
INFILE:
DATA name;
INFILE ‘file.dat’:
INPUT list-of-variables;
1
INPUT list-of-variables;
CARDS;
Type all data here I order of variables followed by (;)
4) Character variables are followed by $
5) You can have the data read in columns, rather than rows: Page 36-
37.
6) Use @@ at the end of INPUT variable-list to ask sas not to cosider a new
line as a new observation but rather a continous from previous step (P. 46).
7) To ask SAS to start from the 3rd line of your data (or any line) use
FIRSTOBS;
MISSOVER for sas not to read more data after it’s done, PAD for
formatted file, DLM delimited space by e.g. a comma (,). P. 50-51
P. 52
2
P. 56-57
P. 72-73
e.g.
3
P. 74-75
IF expression; for example IF sex = ‘f’; (this will only use female data only)
p. 76
P. 78
P. 86
WHERE condition;
e.g. WHERE rain => 50; (only consider rain of equal to or more than
50 inches)
4
P. 92
PROC SORT;
BY variable-1 … variable-n;
You can make a new data set with OUT statement, e.g.
P. 94
P. 96
5
16) DATA summary with PROC MEANS:
PROC FREQ;
TABLES variable-combinations; (e.g. TABLES sex * age)
P. 110
PROC PLOT;
PLOT vertical-variable * horizontal-variable; (plot X * Y)
e.g. (where ‘x’ and ‘#’ the plotting symbol instead of SAS letters)
Also
To tell sas to use the 1st letter of a variable NAME (e.g. DATA $ banan
carambola etc.)
Also you can use the option /OVERLAY; at the end of PROC PLOT to have
2 plots in one.
P. 112
6
19) Combine 2 data sets in one using SET statement:
DATA both;
SET set1 set2;
You can use If and BY statement to sort the new dataet.
P.118-120
P. 122
PROC UNIVARIATE;
VAR variable-list;
You can have other options like normality test and plot, e.g.:
PROC UNIVARIATE PLOT NORMAL;
p. 146
PROC CORR;
VAR sex;
7
WITH age;
p. 148
PROC REG;
MODEL dependent = independent;
(also add)
PLOT y-variable * X-variable =’symbol’:
P. 152
PROC ANOVA;
CLASS variable-list; (this comes 1st)
MODEL dependent = effects; (effect is usually the class variable)
Options like
MEANS effects / options;
e.g.,
CLASS team;
MODEL height = team;
MEANS team/ DUNCAN; (for Duncan separation).
p. 154
8
Example of a SAS program to analyze some data using ANOVA with
treatment mean separation by LSD.
Copy the above code and paste it in SAS, then click RUN.
9
So what this code means:
10
SAS OUTPUT
1 y s 20 22
2 y s 23 25
3 y s 19 20
4 y h 32 35
5 y h 30 34
6 y h 31 33
7 m s 22 21
8 m s 23 22
9 m s 25 22
10 m h 32 35
11 m h 35 36
12 m h 32 38
11
THIS TELLS YOU THE ORDER OF VARIABLES AND NUMBER OF DATA SET
Mango cuttings 00:09 Friday, December 12, 1998 13
tree 2 m y
wood 2 h s
Number of observations 12
12
This is ANOVA for week 1 BY PROC GLM FOR TREE, WOOD, &
Interaction. NOTICE tree and wood are significantly different
(less than 0.05).
Mango cuttings 00:09 Friday, December 12, 1998 14
Sum of
Source DF Squares Mean Square F Value Pr > F
13
This is ANOVA for week 2 BY PROC GLM FOR TREE, WOOD, &
Interaction. NOTICE only wood is significantly different (less
than 0.05).
Mango cuttings 00:09 Friday, December 12, 1998 15
Sum of
Source DF Squares Mean Square F Value Pr > F
14
This is MEANS SEPARATION OF TREE BY LSD FOR WEEK 1
Mango cuttings 00:09 Friday, December 12, 1998 16
NOTE: This test controls the type I comparisonwise error rate not the experimentwise error rate.
Alpha 0.05
Error Degrees of Freedom 8
Error Mean Square 2.666667
Critical Value of t 2.30600
Least Significant Difference 2.1741
A 28.1667 6 m
B 25.8333 6 y
15
This is MEANS SEPARATION OF TREE BY LSD FOR WEEK 2
Mango cuttings 00:09 Friday, December 12, 1998 17
NOTE: This test controls the type I comparisonwise error rate not the experimentwise error rate.
Alpha 0.05
Error Degrees of Freedom 8
Error Mean Square 2.5
Critical Value of t 2.30600
Least Significant Difference 2.1051
A 29.0000 6 m
A
A 28.1667 6 y
16
This is MEANS SEPARATION OF WOOD BY LSD FOR WEEK 1
Mango cuttings 00:09 Friday, December 12, 1998 18
NOTE: This test controls the type I comparisonwise error rate not the experimentwise error rate.
Alpha 0.05
Error Degrees of Freedom 8
Error Mean Square 2.666667
Critical Value of t 2.30600
Least Significant Difference 2.1741
A 32.0000 6 h
B 22.0000 6 s
17
This is MEANS SEPARATION OF WOOD BY LSD FOR WEEK 2
Mango cuttings 00:09 Friday, December 12, 1998 19
NOTE: This test controls the type I comparisonwise error rate not the experimentwise error rate.
Alpha 0.05
Error Degrees of Freedom 8
Error Mean Square 2.5
Critical Value of t 2.30600
Least Significant Difference 2.1051
A 35.1667 6 h
B 22.0000 6 s
18
This is LSMEANS SEPARATION OF INTERACTION FOR WEEK 1 & 2
Mango cuttings 00:09 Friday, December 12, 1998 20
Standard LSMEAN
tree wood week1 LSMEAN Error Pr > |t| Number
i/j 1 2 3 4
Standard LSMEAN
tree wood week2 LSMEAN Error Pr > |t| Number
i/j 1 2 3 4
NOTE: To ensure overall protection level, only probabilities associated with pre-planned
comparisons should be used.
19
This is PROC MEANS OUTPUT TO CALCULATE MEAN, DTANDARD DEVIATION
AND STANDARD ERROR FOR TREE
Mango cuttings 00:09 Friday, December 12, 1998 21
20
This is PROC MEANS OUTPUT TO CALCULATE MEAN, DTANDARD DEVIATION
AND STANDARD ERROR FOR WOOD
Mango cuttings 00:09 Friday, December 12, 1998 22
21