You are on page 1of 18

MTH 3405

APPLICATIONS OF SELECTED
STATISTICAL PACKAGE
THE PROC STEP
 Statements in the PROC step are commands that process or analyse a SAS data set.
 So, the PROC step is a block of statements that specify the data set to be analysed, the
procedure to be used, and any further details of the analysis.
 The step begins with a PROC statement and ends with a run statement or when the next data
or proc step starts.
THE PROC STATEMENT
 The PROC statement names the procedure to be used and specify the DATA = option for the
analysis.
 If the option is omitted, the procedure uses the most recently created data set.
 General format:

 For example: The PROC PRINT Procedure


THE VAR STATEMENT
 The var statement specifies the variables that are to be processed by the proc step.
 For example:

OUTPU
T

 Restricts the printout to the three variables mentioned, whereas the default would be to print
all variables.
THE WHERE STATEMENT
 The WHERE statement selects the observations to be processed.
 The keyword WHERE is followed by a logical condition, and only those observations for
which the condition is true are included in the analysis.
 For example:

OUTPUT
THE BY STATEMENT
 The observations are grouped according to the values of the variable named on the BY
statement and a separate analysis is conducted for each group.
 When a BY statement appears as part of the PRINT procedure, the procedure expects the data
to be sorted in the order of the BY variables.
 For example:

output
GLOBAL STATEMENTS
 Global statements can occur at any point in a SAS program and remain in effect until reset.
 The title statement is a global statement. For example:

 Multiple lines of titles can betitle 'Analysis


specified of Slimming
with Club
the title2 Data'; for the second line, title3 for
statement
the third line, and so on up to ten.
 Comment statements are global statements in the sense that they can occur anywhere. For
example:

* this is a comment;

/* this is also a comment*/


 The options and goptions global statements are used to set SAS system options and graphics
options.
 Several options can be set on a single options statement;

 The goptions statement is analogous, but sets graphical options.


THE SUM STATEMENT
 The SUM statement specifies variables whose values are to be totalled.
 Example:

 Totals for the variables in the SUM statement are computed.


THE PROC SORT PROCEDURE
 You can specify as many BY variables.  By default, SAS sorts data in ascending
order.
 In the PROC SORT step, a BY statement
 If needed, the sorted output can be written to
specifies the variables to be used for a new SAS data set using an ‘OUT =’ option
sorting. on the PROC SORT statement to name the
 In the SORT procedure, observations are new data set.
first arranged in the increasing order of the
values of the first variable specified in the
BY statement.
 Within each of the resulting groups,
observations are arranged in the increasing
order of the values of the second variable
specified and so on.
 Example:
GRAPHING DATA IN SAS
 This module demonstrates how to obtain basic high resolution graphics using SAS.
 In SAS, several of the statistical procedures can produce high-resolution graphics.
 If the procedure does not have graphical capabilities built in, or different types of graphs are
required, the general-purpose graphical procedures within SAS/GRAPH may be used.
 This example uses a data file about 26 automobiles with their make, mpg, repair record,
weight, and whether the car was foreign or domestic. 
THE GCHART PROCEDURE
 Create vertical Bar Charts with proc
gchart and the vbar statement.  
 The vbar statement produces a vertical bar chart, and while optional the title statement allows
you to label the chart. 
 Since mpg is a continuous variable the automatic “binning” of the data into five groups yields
a readable chart.  The midpoint of each bin labels the respective bar.
 You can control the number of bins for a continuous variable with the level= option on
the vbar statement.
 The program below creates a vertical bar chart with seven bins for mpg.
 On the other hand, rep78 has only four categories and SAS’s
tendency to bin into five categories and use midpoints would not
do justice to the data. 
 So when you want to use the actual values of the variable to label
each bar you will want to use the discrete option on
the vbar statement.
 Other charts may be easily produced simply by changing vbar.
 For example, we want produce a horizontal bar chart by replacing vbar with hbar.
 We also can produce a pie chart by replacing hbar in the above example with pie. 
 The value=, percent=, and slice= options control the location of each of those labels.

You might also like