The script begins by creating a dataset named `function_study` containing participant information (ID, sex, disability, height, weight) using data directly embedded via the DATALINES clause. Then, it uses `PROC PRINT` to display all observations from the dataset. Finally, `PROC FREQ` is used to calculate the frequency and percentage distribution for the `disability` variable to determine the proportion of participants who reported a disability.
Data Analysis
Type : INTERNAL_CREATION
The `function_study` dataset is created directly within the script using the DATALINES clause, making the data self-contained and not dependent on external sources or SASHELP.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates the `function_study` dataset using the data provided directly after the DATALINES statement. It defines the variables `id` (character), `sex` (character), `disability` (character), `ht_in` (numeric for height in inches) and `wgt_lbs` (numeric for weight in pounds).
Copied!
/*
Step 1. Highlight and sumbmit the data step below.
*/
data function_study;
input id $ sex $ disability $ ht_in wgt_lbs;
datalines;
001 Male No 71 190
002 Female No 60 112
003 Female Yes 64 130
004 Female No 65 154
005 Male No 73 173
006 Male No 69 182
007 Female No 68 140
008 Male No 73 185
009 Male Yes 71 199
010 Male Yes 66 155
011 Male No 71 213
012 Female No 69 151
013 Female Yes 66 147
014 Female No 68 196
015 Male . 75 212
016 Female No 69 190
017 Female No 66 194
018 Male . 71 194
019 Female No 65 176
020 Female No 65 102
run;
1
/*
2
Step 1. Highlight and sumbmit the data step below.
3
*/
4
DATA function_study;
5
INPUT id $ sex $ disability $ ht_in wgt_lbs;
6
DATALINES;
7
001 Male No 71190
8
002 Female No 60112
9
003 Female Yes 64130
10
004 Female No 65154
11
005 Male No 73173
12
006 Male No 69182
13
007 Female No 68140
14
008 Male No 73185
15
009 Male Yes 71199
16
010 Male Yes 66155
17
011 Male No 71213
18
012 Female No 69151
19
013 Female Yes 66147
20
014 Female No 68196
21
015 Male . 75212
22
016 Female No 69190
23
017 Female No 66194
24
018 Male . 71194
25
019 Female No 65176
26
020 Female No 65102
27
RUN;
2 Code Block
PROC PRINT
Explanation : This `PROC PRINT` procedure generates a report listing all observations (rows) and all variables (columns) from the `function_study` dataset. This is useful for a quick inspection of the data.
Copied!
/*
Step 2. Create a list report that shows all the observations in function_study.
*/
proc print data = function_study;
run;
1
/*
2
Step 2. Create a list report that shows all the observations in function_study.
3
*/
4
PROC PRINTDATA = function_study;
5
RUN;
3 Code Block
PROC FREQ
Explanation : This `PROC FREQ` procedure calculates the frequency and percentage distribution for the categorical variable `disability` in the `function_study` dataset. It helps determine the proportion of participants who reported a disability and visualize the distribution of this variable.
Copied!
/*
Step 3. Create a frequency report to calculate the percentage of participants who
self-report having a disability.
*/
proc freq data = function_study;
table disability;
run;
1
/*
2
Step 3. Create a frequency report to calculate the percentage of participants who
3
self-report having a disability.
4
*/
5
PROC FREQDATA = function_study;
6
TABLE disability;
7
RUN;
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.
Copyright Info : * ============================================================================;
* Descriptive Analysis I
* Practice: Calculate Frequencies and Percentages
* This code is posted for your benefit; however, I highly recommend that you
* practice typing your own SAS programs as well. With the SAS programming
* language, as with all new languages, immersion seems to be the best way to
* learn.
* ============================================================================;
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.