The script is structured into several independent sections. The first section creates a 'scoredata' dataset and derives a 'subsetscoredata' subset by filtering observations based on a condition on 'scorevalues'. The second section initializes a 'demography' dataset to then perform frequency analyses on the 'Gender' variable with `PROC FREQ` and descriptive statistics on 'Age', 'Weight', 'Height' with `PROC MEANS`. The main section creates a 'biology' dataset and applies a series of statistical analyses: calculating means for 'Age', 'Height', 'Weight', then descriptive statistics grouped by 'Sex', and subsequently by 'Year' and 'Sex'. A `PROC MEANS` is specifically used to save the calculated descriptive statistics (means, standard deviations, skewness, medians) into a new dataset named 'Stats_biology'. Finally, the script uses `PROC UNIVARIATE` for a distribution analysis of 'Height' and `PROC MEANS` with the `maxdec=2` option to format the output of statistics.
Data Analysis
Type : CREATION_INTERNE
All datasets ('scoredata', 'subsetscoredata', 'demography', 'biology', 'Stats_biology') are created directly within the script using `DATA STEP` blocks with embedded `datalines` or are derived from these internal datasets. No external data sources (files, databases) are referenced or required for script execution.
1 Code Block
DATA STEP Data
Explanation : Creates a dataset named 'scoredata' with two variables, 'A' (character) and 'Scorevalues' (numeric), using data provided directly via `datalines`.
Copied!
data scoredata;
input A $ Scorevalues;
datalines;
P 77 P 76 P 74 P 72 P 78
D 80 D 84 D 88 D 87 D 90
run;
1
DATA scoredata;
2
INPUT A $ Scorevalues;
3
DATALINES;
4
P 77 P 76 P 74 P 72 P 78
5
D 80 D 84 D 88 D 87 D 90
6
RUN;
2 Code Block
PROC PRINT
Explanation : Displays the content of the 'scoredata' dataset in the standard SAS output.
Copied!
proc print data=scoredata;
1
PROC PRINTDATA=scoredata;
3 Code Block
DATA STEP Data
Explanation : Creates a new dataset named 'subsetscoredata' from 'scoredata', including only observations where the value of 'Scorevalues' is strictly greater than 78.
Copied!
data subsetscoredata;
set scoredata;
if scorevalues>78;
run;
1
DATA subsetscoredata;
2
SET scoredata;
3
IF scorevalues>78;
4
RUN;
4 Code Block
PROC PRINT
Explanation : Displays the content of the 'subsetscoredata' dataset in the standard SAS output.
Copied!
proc print data=subsetscoredata;
1
PROC PRINTDATA=subsetscoredata;
5 Code Block
DATA STEP Data
Explanation : Creates a dataset named 'demography' with 'Gender' (character), 'Age', 'Weight', and 'Height' (numeric) variables, using data provided via `datalines`. The `title Demography;` statement sets a title for subsequent procedure outputs.
Copied!
*Q4;
data demography;
input Gender $ Age Weight Height;
datalines;
M 50 68 155
F 23 60 165
M 65 72 180
F 35 55 154
M 15 35 158
run;
title Demography;
1
*Q4;
2
DATA demography;
3
INPUT Gender $ Age Weight Height;
4
DATALINES;
5
M 5068155
6
F 2360165
7
M 6572180
8
F 3555154
9
M 1535158
10
RUN;
11
title Demography;
6 Code Block
PROC FREQ
Explanation : Calculates and displays the frequency distribution for the 'Gender' variable of the 'demography' dataset, showing the count and percentage of occurrences for each gender category.
Copied!
proc freq data=demography;
table Gender;
1
PROC FREQDATA=demography;
2
TABLE Gender;
7 Code Block
PROC MEANS
Explanation : Calculates basic descriptive statistics (N, mean, standard deviation, minimum, maximum) for the 'Age', 'Weight', and 'Height' variables of the 'demography' dataset.
Copied!
proc means data=demography;
Var Age Weight height;
1
PROC MEANSDATA=demography;
2
Var Age Weight height;
8 Code Block
DATA STEP Data
Explanation : Creates a dataset named 'biology' with 'Id' (numeric), 'sex' (character), 'Age', 'Year', 'Height', and 'Weight' (numeric) variables, using data provided directly via `datalines`.
Copied!
*------------------------------------;
data biology;
input Id sex $ Age Year Height Weight;
datalines;
7389 M 24 4 69.2 132.5
3945 F 19 2 58.5 112.8
4721 F 20 2 65.3 98.6
1835 F 24 4 62.8 102.5
9541 M 21 3 72.5 152.3
2957 M 22 3 67.3 145.8
2158 F 21 2 59.8 104.5
4296 F 25 3 62.5 132.5
4824 M 23 4 74.5 184.4
5736 M 22 3 69.1 149.5
8765 F 19 1 67.3 130.5
5734 F 18 1 64.3 110.2
run;
1
*------------------------------------;
2
DATA biology;
3
INPUT Id sex $ Age Year Height Weight;
4
DATALINES;
5
7389 M 24469.2132.5
6
3945 F 19258.5112.8
7
4721 F 20265.398.6
8
1835 F 24462.8102.5
9
9541 M 21372.5152.3
10
2957 M 22367.3145.8
11
2158 F 21259.8104.5
12
4296 F 25362.5132.5
13
4824 M 23474.5184.4
14
5736 M 22369.1149.5
15
8765 F 19167.3130.5
16
5734 F 18164.3110.2
17
RUN;
9 Code Block
PROC PRINT
Explanation : Displays the complete content of the 'biology' dataset in the standard SAS output.
Copied!
proc print data=biology;
run;
1
PROC PRINTDATA=biology;
2
RUN;
10 Code Block
PROC MEANS
Explanation : Calculates basic descriptive statistics for the 'Age', 'Height', and 'Weight' variables of the 'biology' dataset.
Copied!
*Q1) Obtain the means of Age,Height and Weight.;
proc means data=biology;
var Age Height Weight;
run;
1
*Q1) Obtain the means of Age,Height and Weight.;
2
PROC MEANSDATA=biology;
3
var Age Height Weight;
4
RUN;
11 Code Block
PROC MEANS
Explanation : Calculates descriptive statistics for the 'Age', 'Height', and 'Weight' variables of the 'biology' dataset, grouped by each category of the 'Sex' variable.
Copied!
*Q2) Obtain the Discptive statistics of Age Height and Weight by Gender wise.;
proc means data=biology;
var Age Height Weight;
class Sex;
run;
1
*Q2) Obtain the Discptive statistics of Age Height and Weight by Gender wise.;
2
PROC MEANSDATA=biology;
3
var Age Height Weight;
4
class Sex;
5
RUN;
12 Code Block
PROC MEANS
Explanation : Calculates descriptive statistics for the 'Age', 'Height', and 'Weight' variables of the 'biology' dataset, grouped jointly by the 'Year' and 'Sex' variables.
Copied!
*Q3) Obtain the Discptive statistics of Age Height and Weight by Gender and year wise.;
proc means data=biology;
var Age Height Weight;
class year sex;
1
*Q3) Obtain the Discptive statistics of Age Height and Weight by Gender and year wise.;
2
PROC MEANSDATA=biology;
3
var Age Height Weight;
4
class year sex;
13 Code Block
PROC MEANS Data
Explanation : Calculates descriptive statistics (means, standard deviations, skewness, and medians) for the 'Height' and 'Weight' variables of the 'biology' dataset, grouped by 'Year' and 'Sex'. The results are stored in a new dataset named 'Stats_biology'.
Copied!
*Q4) store Descriptive statistics in a specific variable.;
proc means data=biology;
class year sex;
Output out=Stats_biology mean=av_height av_weight std=sd_height sd_weight skewness=sk_height sk_weight median=md_height md_weight;
1
*Q4) store Descriptive statistics in a specific variable.;
Explanation : Displays the content of the 'Stats_biology' dataset, which contains the descriptive statistics calculated and stored by the previous `PROC MEANS`.
Copied!
proc print data=Stats_biology;
run;
1
PROC PRINTDATA=Stats_biology;
2
RUN;
15 Code Block
PROC UNIVARIATE
Explanation : Generates detailed univariate statistics, including moments, quantiles, normality tests, and graphs (if activated), for the 'Height' variable of the 'biology' dataset, to examine its distribution.
Copied!
*Q5) Use univariate command to check the distribution of data.;
proc univariate data=biology;
var Height;
run;
1
*Q5) Use univariate command to check the distribution of data.;
2
PROC UNIVARIATEDATA=biology;
3
var Height;
4
RUN;
16 Code Block
PROC MEANS
Explanation : Calculates basic descriptive statistics for all numeric variables of the 'biology' dataset, formatting the numeric outputs to display a maximum of two decimal places using the `maxdec=2` option.
Copied!
*Q6) Use proc mean command and get the output upto two decimel;
proc means data=biology maxdec=2;
run;
1
*Q6) Use
2
proc mean command and get the output upto two decimel;
3
PROC MEANS
4
DATA=biology maxdec=2;
5
RUN;
6
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.