To Projects
CSC 423 -- Lab 1
Use the ExamSco and NIST Examples to help you write your SAS and/or R code.
The blood pressure of fourteen persons is measured, both in standing and supine position.
The blood pressure readings are recorded in the datasets
blood-pressure1.txt and
blood-pressure2.txt. The SAS and R scripts perform the following tasks:
- Create datasets named bp1 and bp2 that contain the data from the input files
blood-pressure1.txt and blood-pressure2.txt, respectively. If you are using SAS,
define labels for the variables in each dataset.
- Print each dataset in 1.
- For bp1, obtain these univariate statistics:
x
s_{x}
Percentiles 1, 5, 25, 50, 75, 95, 99
Interquartile Range
If you are using SAS, compute these statistics using both proc means and proc univariate.
If you are using R, use these functions: mean, sd, quantile, and IQR.
Note: if
you perform the percentile calculations in both SAS and R, you will see that
different percentile values are obtained. Don't worry about these
differences. SAS has 5 different percentile calculation methods;
R has 9 quantile calculation methods.
- (Optional) If you are using SAS, repeat the analyses in Problem 3 using bp2.
Skip this problem if you are using R.
- Using bp1, create three histograms of the Standing and Supine columns, one
histogram with the default width, one histogram with bins larger than the
default (less bins than the default), and one histogram with bins smaller than the default (more bins than the default).
Note that the default histogram has bins with midpoints at 60, 180, 300, 420, 540
for Standing, so you could use 0 to 600 for the range of the
histogram.
- Using bp1, create normal plots for the Standing and Supine columns.
- Using bp2, create side-by-side boxplots for Press using the independent
variable Pos.
- Find 95% confidence intervals of the true pressures of the populations
represented in bp1.
- Delete any bad observations from bp1. Then perform a paired two-sample
t-test using the "cleaned" dataset bp1.
- Delete any bad observations from bp2. Then perform an independent
two-sample t-test using the "cleaned" dataset bp1.
Tips and Hints for Lab1
- Set your Windows File Explorer to show file extensions. See the
very bottom announcement on the Announcements Page.
- SAS: use labels for your variables to increase the readability of the output. A label is
an expanded, human readable explanation of a variable. For example:
label press = "Blood Pressure"
pos = "Position in which Blood Pressure was Measured";
Labels will also be applied to graphs.
- R: use the cat function to provide explanations in your output. cat is more flexible
function than print for printing captions and explanations. You can include new line tokens \n
in what is printed for example:
cat("\n\nSample Mean of Blood Pressure\n")
- SAS: when using proc univariate to produce histograms or normal plots,
you can suppress the usual printed output with the noprint option if you only want
the plots.
- R: when creating graphs, use the xlab and ylab arguments to customize the x and y axis labels.
- R: use the t.ttest function to obtain a confidence interval for the population mean.
- SAS: use the bp1 dataset with one column for each treatment group for the paired-sample t-test;
use the bp2 dataset with a categorical variable that labels the treatment groups for the
independent two-sample t-test.
- R: use the bp1 dataset for both the paired-sample t-test and the independent two-sample t-test.
- SAS: to export the graphs to include in your Word document for Project 1, right click on the graph in the Results Viewer
and select Save Picture.
- R: to create a PNG file with a single graph that can be included in your Word document for Project 1,
use the R functions png and dev.off. For example:
png("hist1.png")
hist(bp1$standing)
dev.off( )