SAS tutorial 10/25
Overview
• PROC SUMMARY• PROC SORT
• LABEL• GOTO
SUMMARY & SORT
PROC SUMMARY
• Provides data summarization tools that compute descriptive statistics for variables across all observations or within groups of observations.
• Similar to PROC MEANS
Syntax
Differences to MEANS
• Cannot do t-test• Cannot calculate confidence limits• Cannot estimate quantiles
Example 1
DATA creativity
Result
Use “BY” option
“Not sorted in ascending sequence”
PROC SORT
• Orders SAS data set observations by the values of one or more character or numeric variables
Syntax
Example 2
Result
Example 1
Result
LABEL & GOTO
GOTO
• Directs program execution immediately to the statement label that is specified and, if followed by a RETURN statement, returns execution to the beginning of the DATA step.
(Statement) Label
• Specifies a statement label that identifies the GOTO destination. The destination must be within the same DATA step. You must specify the label argument.
Example 3
• DATA info;Input X @@;If 1<=X<=5 then go to OK;
X=3; count+1;OK:SUMX+X;Cards;
• DATA info;Input X @@;If X<1 or X>5 then do;
X=3; count+1;end;SUMX+X;Cards;
X1 X1’ SUMX
1 1 1
2 2 3
6 3 6
4 4 10
7 3 13
1 1 14
Return
• DATA info;Input X @@;If 1<=X<=5 then go to OK;
X=3; count+1;Return;OK:SUMX+X;Cards;
• DATA info;Input X Y;If X<1 or X>5 then do;
X=3; count+1;End;else SUMX+X;Cards;X1 X1’ SUMX
1 1 1
2 2 3
6 3 3
4 4 7
7 3 7
1 1 8
Top Related