To create a SAS chunk we need to add the SAS class. We also need to set eval=FALSE or else R will try to compile this code!
/st101s01.sas/ /Part A/
/* This is a SAS program that analyzes the distribution of
two interval variables (BodyTemp and HeartRate) using a
histogram with normal and kernel density plots. */
/* Define a macro variable named interval that contains
the names of the interval variables. */
%let interval=BodyTemp HeartRate;
/* Turn on ODS graphics for generating graphical output,
and specify that only histograms will be displayed. */
ods graphics;
ods select histogram;
/* Use PROC UNIVARIATE to generate a histogram with
normal and kernel density plots for the interval variables. */
proc univariate data=STAT1.NormTemp noprint;
var &interval;
/* Analyze the interval variables specified in the macro variable interval. */
histogram &interval / normal kernel;
/* Generate a histogram with normal and kernel density plots for the interval variables. */
inset n mean std / position=ne;
/* Include the sample size, mean, and standard deviation in the upper right corner of the graph. */
title "Interval Variable Distribution Analysis";
/* Specify a title for the graph. */
run;
/* Reset the title to blank. */
title;
/st101s01.sas/ /Part B/
/* This part of the SAS program tests whether the mean body
temperature is significantly different from the conventional value of 98.6°F. */
/* Use PROC TTEST to perform a one-sample t-test for the BodyTemp variable. /
proc ttest data=STAT1.NormTemp h0=98.6
plots(only shownull)=interval;
var BodyTemp; / Analyze the BodyTemp variable. /
title 'Testing Whether the Mean Body Temperature = 98.6'; / Specify a title for the output. */
run;
/* Reset the title to blank. */
title;
We can use R chunks as we already know and love.
3 + 5
## [1] 8