The script begins by creating the 'Athelate' dataset via datalines, where a new variable (ABP - Mean Arterial Pressure) is calculated. The content of this dataset is then displayed. A copy, 'Practice.Athelate', is created for further analysis. Descriptive statistics (means, standard deviations) are calculated and displayed for 'Athelate's numerical variables via PROC MEANS. Several univariate analyses are performed on the 'Age' variable of 'Athelate' and 'Practice.Athelate', including confidence intervals and normality tests. Data visualization is then addressed with PROC SGPLOT to generate vertical and horizontal boxplots of the SBP variable, and PROC PLOT for a scatterplot between SBP and DBP, all for the 'Practice.Athelate' dataset. Finally, a second 'disease' dataset is created via datalines to analyze cross-frequencies between 'Severity' and 'Herd_size' using PROC FREQ, including Chi-square tests.
Data Analysis
Type : CREATION_INTERNE
All main datasets ('Athelate' and 'disease') are created directly within the SAS script via DATALINES statements, integrating raw data into the code. The 'Practice.Athelate' and 'desp_athelate' datasets are derivations of this internal data. No external data sources (CSV files, databases, etc.) are directly read by this script.
1 Code Block
DATA STEP Data
Explanation : Creates the SAS dataset 'Athelate' by reading the data provided via the DATALINES statement. It defines the variables Id, Age, Race (character), SBP, DBP, HR (numeric), and calculates a new variable 'ABP' (Mean Arterial Pressure) from SBP and DBP.
Copied!
data Athelate;
input Id Age Race $ SBP DBP HR;
ABP=1/3*SBP+2/3*DBP;
datalines;
4101 18 W 130 80 60
4102 18 W 140 90 70
4103 19 B 120 70 64
4104 17 B 150 90 76
4105 18 B 124 86 72
4106 19 W 145 94 70
4107 23 B 125 78 68
4108 21 W 140 85 74
4109 18 W 150 82 65
4110 20 W 145 95 75
run;
1
DATA Athelate;
2
INPUT Id Age Race $ SBP DBP HR;
3
ABP=1/3*SBP+2/3*DBP;
4
DATALINES;
5
410118 W 1308060
6
410218 W 1409070
7
410319 B 1207064
8
410417 B 1509076
9
410518 B 1248672
10
410619 W 1459470
11
410723 B 1257868
12
410821 W 1408574
13
410918 W 1508265
14
411020 W 1459575
15
RUN;
2 Code Block
PROC PRINT
Explanation : Displays the content of the 'Athelate' dataset. The 'noobs' option suppresses the display of the default numeric observation column.
Copied!
proc print data=Athelate noobs;
1
PROC PRINTDATA=Athelate noobs;
3 Code Block
DATA STEP Data
Explanation : Creates a new dataset named 'Practice.Athelate' in the 'Practice' library (if defined, otherwise in WORK) by copying all observations and variables from the 'Athelate' dataset.
Copied!
data Practice.Athelate;
SET Athelate;
1
DATA Practice.Athelate;
2
SET Athelate;
4 Code Block
PROC MEANS Data
Explanation : Calculates descriptive statistics (mean and standard deviation) for the variables 'Age', 'SBP', 'DBP', 'HR' from the 'Athelate' dataset. The results of the means and standard deviations for 'Age' and 'SBP' are saved in a new dataset 'desp_athelate'.
Copied!
proc means data=Athelate;
var Age SBP DBP HR;
output out=desp_athelate mean=av_Age av_SBP std=sd_Age sd_SBP;
Explanation : Displays the content of the 'desp_athelate' dataset, which contains the previously calculated descriptive statistics.
Copied!
proc print data=desp_athelate;
1
PROC PRINTDATA=desp_athelate;
6 Code Block
PROC UNIVARIATE
Explanation : Performs a univariate analysis on the 'Age' variable of the 'athelate' dataset. It calculates a basic confidence interval (type=upper, alpha=0.10) and tests the null hypothesis that the mean of 'Age' is equal to 120 (mu0=120).
Copied!
proc univariate data=athelate cibasic(type=upper alpha=0.10) mu0=120;
var Age;
Explanation : Performs a univariate analysis on all numeric variables in the 'athelate' dataset, providing descriptive statistics and a default basic confidence interval for the mean.
Copied!
proc univariate data=athelate cibasic;
1
PROC UNIVARIATEDATA=athelate cibasic;
8 Code Block
PROC UNIVARIATE
Explanation : Performs a univariate analysis on the 'Age' variable of the 'Practice.Athelate' dataset. The 'plots' option generates default graphs and 'normaltest' performs normality tests. The 'histogram' statement creates a histogram of the 'Age' variable.
Copied!
proc univariate data=Practice.Athelate plots normaltest;
var Age;
histogram;
1
2
PROC UNIVARIATE
3
DATA=Practice.Athelate plots normaltest;
4
var Age;
5
histogram;
6
9 Code Block
PROC SGPLOT
Explanation : Generates a vertical boxplot ('vbox') of the 'SBP' variable from the 'practice.athelate' dataset. The grid is enabled on the Y-axis and a title is set for the graph.
Copied!
proc sgplot data=practice.athelate;
vbox SBP;
yaxis grid;
title "Boxplot of SBP Variable From Athelate data";
1
PROC SGPLOTDATA=practice.athelate;
2
vbox SBP;
3
yaxis grid;
4
title "Boxplot of SBP Variable From Athelate data";
10 Code Block
PROC SGPLOT
Explanation : Generates a horizontal boxplot ('hbox') of the 'SBP' variable from the 'Practice.Athelate' dataset, with a specific title.
Copied!
proc sgplot data=Practice.Athelate;
hbox SBP;
title "Horizontal Boxplot of SBP Variable From Athelate data";
1
2
PROC SGPLOT
3
DATA=Practice.Athelate;
4
hbox SBP;
5
title "Horizontal Boxplot of SBP Variable From Athelate
6
data";
7
11 Code Block
PROC PLOT
Explanation : Creates a scatterplot of the 'SBP' and 'DBP' variables from the 'Practice.Athelate' dataset, with 'SBP' on the Y-axis and 'DBP' on the X-axis, and a descriptive title.
Copied!
proc plot data=Practice.Athelate;
plot SBP*DBP;
title "Scatter plot of SBP and DBP Variable";
1
2
PROC PLOT
3
DATA=Practice.Athelate;
4
plot SBP*DBP;
5
title "Scatter plot of SBP and DBP Variable";
6
12 Code Block
DATA STEP Data
Explanation : Creates the SAS 'disease' dataset by reading the data provided via the DATALINES statement. It defines the variables 'Severity' (character), 'Herd_size' (character) and 'Count' (numeric).
Explanation : Displays the content of the 'disease' dataset.
Copied!
proc print data=disease;
1
PROC PRINTDATA=disease;
14 Code Block
PROC FREQ
Explanation : Performs a frequency analysis for the variables 'Severity' and 'Herd_size' from the 'disease' dataset. The 'weight count' statement indicates that the 'count' variable represents the frequency of observations. The second 'tables' block requests additional statistics, including the Chi-square test ('chisq'), and suppresses the display of column, row, and global percentages ('nocol', 'nopercent', 'norow'), as well as measures of association.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.