0% found this document useful (0 votes)
4 views139 pages

L05-Visualizing & Structuring Data - Part 2

The document covers statistical procedures in SAS, focusing on PROC FREQ, PROC MEANS, and PROC UNIVARIATE for data analysis. It explains how to create frequency tables, compute descriptive statistics, and analyze data distributions, including measures like skewness and kurtosis. Additionally, it introduces the Output Delivery System (ODS) for enhanced output formatting and provides exercises for practical application.

Uploaded by

totearsapphire
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views139 pages

L05-Visualizing & Structuring Data - Part 2

The document covers statistical procedures in SAS, focusing on PROC FREQ, PROC MEANS, and PROC UNIVARIATE for data analysis. It explains how to create frequency tables, compute descriptive statistics, and analyze data distributions, including measures like skewness and kurtosis. Additionally, it introduces the Output Delivery System (ODS) for enhanced output formatting and provides exercises for practical application.

Uploaded by

totearsapphire
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SEHS2323 Statistical

Data Analysis
L05 - Visualizing & Structuring Data – Part 2
Summary statistics -
PROC FREQ
Proc Freq
• The FREQ procedure produces one-way to n-way frequency and contingency
(crosstabulation) tables.
• For two-way tables, PROC FREQ computes tests and measures of association.
• For n-way tables, PROC FREQ provides stratified analysis by computing statistics
within strata and across strata.
• For one-way frequency tables, PROC FREQ provides goodness-of-fit tests for
equal proportions or specified null proportions.
• For one-way tables, PROC FREQ also provides confidence limits and tests for
binomial proportions, including tests for non-inferiority and equivalence.
Proc Freq
• For contingency tables, PROC FREQ can compute various statistics to examine the
relationships between two classification variables.
• For some pairs of variables, you might want to examine the existence or strength of any
association between the variables.
• To determine if an association exists, PROC FREQ computes chi-square tests.
• To estimate the strength of an association, PROC FREQ computes measures of association
that tend to be close to zero when there is no association and close to the maximum (or
minimum) value when there is perfect association.
• The statistics for contingency tables include the following:
➢chi-square tests and measures
➢measures of association
➢risks (binomial proportions) and risk differences for 2x2 tables
➢odds ratios and relative risks for 2x2 tables
➢tests for trend
➢tests and measures of agreement
➢Cochran-Mantel-Haenszel statistics
Statistical Procedures
Statistical Procedures
➢ Numeric missing values
are represented by a
single period (.)
Statistical Procedures
If we change to “courseno”…
Summary statistics -
PROC MEANS
Proc Means
• The MEANS procedure provides data summarization tools to compute
descriptive statistics for variables across all observations and within groups
of observations. For example, PROC MEANS does the following:
• calculates descriptive statistics based on moments
• estimates quantiles, which includes the median
• calculates confidence limits for the mean
• identifies extreme values
• performs a t test
• By default, PROC MEANS displays output. You can also use the OUTPUT statement
to store the statistics in a SAS data set.
Statistical Procedures
Summary statistics -
PROC UNIVARIATE
Proc Univariate
• The PROC UNIVARIATE statement is required to invoke the UNIVARIATE procedure.
• If you do not specify any other statements, it produces a variety of statistics that
summarize the data distribution of each analysis variable:

• sample moments
• basic measures of location and variability
• confidence intervals for the mean, standard deviation, and variance
• tests for location
• tests for normality
• trimmed and Winsorized means
• robust estimates of scale
• quantiles and related confidence intervals
• extreme observations and extreme values
• frequency counts for observations
• missing values
Statistical Procedures
SKEWNESS (偏態係數)
• Skewness is usually described as a measure of a dataset’s symmetry –
or lack of symmetry. A perfectly symmetrical data set will have a
skewness of 0. The normal distribution has a skewness of 0.
• The skewness is defined as (Advanced Topics in Statistical Process
Control, Dr. Donald Wheeler, [Link]):
SKEWNESS (偏態係數)
SKEWNESS (偏態係數)

[Link]
KURTOSIS (峰度)
• How to define kurtosis? This is really the reason this article was
updated. If you search for definitions of kurtosis, you will see some
definitions that includes the word “peakedness” or other similar
terms. For example,

“Kurtosis is the degree of peakedness of a distribution” – Wolfram MathWorld


“We use kurtosis as a measure of peakedness (or flatness)” – Real Statistics Using Excel

• You can find other definitions that include peakedness or flatness when
you search the web. The problem is these definitions are not correct. Dr.
Peter Westfall published an article that addresses why kurtosis does not
measure peakedness (link to article).
• “Kurtosis was originally thought to be a
measure the “peakedness” of a
distribution. However, since the central portion
of the distribution is virtually ignored by this
KURTOSIS (峰 parameter, kurtosis cannot be said to measure
peakedness directly. While there is a
度) correlation between peakedness and kurtosis,
the relationship is an indirect and imperfect one
at best.”
KURTOSIS (峰度)
• So, kurtosis is all about the tails of the distribution – not the
peakedness or flatness. It measures the tail-heaviness of the
distribution.
• Kurtosis is defined as:
[Link]
Output Delivery System
(ODS) - Report
Formats
Output Delivery System (ODS)
• In SAS, a procedure or a DATA step supplies raw data and the name of a table
definition that contains formatting instructions.
• Traditional SAS output is designed for a traditional line–printer.
• This type of output has limitations that prevent you from getting the most value
from your results.
• ODS is designed to overcome the limitations of traditional SAS output.
• It provides a method of delivering output in a variety of formats, and makes the
formatted output easy to access.
Output Delivery System (ODS)
ODS with Proc Freq
Output Delivery System (ODS)
SAS - Frequency Distributions
SAS - Frequency
Distributions - Example 1
ODS TRACE Statement
ODS TRACE Statement
ODS TRACE Statement
ODS TRACE Statement
ODS TRACE Statement
ODS TRACE Statement
• Writes to the SAS log a record of each output object that is created,
or suppresses the writing of this record.
ODS TRACE Statement
by using the name of
the table, we obtained
using the ods trace off
in the previous steps
by running this code
you will now see
SAS - Frequency Distributions – Comparison: Code
SAS - Frequency Distributions – Comparison: log
SAS - Frequency Distributions – Comparison: Result
SAS - Frequency Distributions – Comparison: Output Data
SAS - Frequency
Distributions -
Example 2
ODS with Proc
Means
ODS with Proc Means
SAS - Cross
Tabulations
• Cross tabulation involves producing
cross tables also called contingent
tables using all possible combinations
of two or more variables. In SAS it is
SAS - Cross created using PROC FREQ along with
the TABLES option. For example - if we
Tabulations need the frequency of each model for
each make in each car type category,
then we need to use the TABLES option
of PROC FREQ.
SAS - Cross Tabulations
SAS - Cross Tabulations
SAS - Cross Tabulations
SAS - Cross Tabulations
SAS - Cross Tabulations
SAS - Cross Tabulations
SAS - Cross Tabulations
Exercises
Exercises
• You are required to use Cars from
SASHelp to create Cross Tabulations for
the following variables:
• 1) Make and Type.
• 2) Model x origin and drivertrain.
• 3) Make, Model x Type, Cylinders

data CARS2;
set [Link];
RUN;
Submiss to e-
learning platform
SEHS2323 Statistical Data
Analysis
Structuring data
APPEND Procedure

• The APPEND procedure (and APPEND statement of the DATASETS


procedure) is an efficient method for concatenating observations
from a smaller data set to a larger data set. The BASE= data set option
is reserved for the larger of the two data sets with the DATA= option
for the smaller data set.
Exercise 1
Exercise 1
Exercise 1
data students;
input Name $ Grade Age;
cards;
Alice 85 20
Bob 90 21
Charlie 78 22
David 92 21
Eva 88 20
;
run;
Exercise 1
Exercise 1

You might also like