Raw data is included directly in the SAS script via a DATALINES statement within a DATA step, thus creating dataset 'a'. There are no dependencies on external data sources or pre-existing SAS libraries like SASHELP for the main dataset.
1 Code Block
DATA STEP Data
Explanation : This block creates the SAS dataset named 'a'. It reads the 'drug' and 'disease' variables, then uses a 'do i=1 to 6' loop to read six observations of the 'y' (response) variable per input line, thus creating six rows for each 'drug-disease' combination if the data is complete. The 'datalines' statement marks the beginning of raw data integrated directly into the script. The presence of dots ('.') indicates missing values, which makes the design unbalanced.
Explanation : This block executes the GLM procedure for an analysis of variance. The 'class' statement declares 'drug' and 'disease' as categorical variables. The 'model' statement specifies that 'y' is the dependent variable and that 'drug', 'disease', as well as their interaction 'drug*disease' are the predictors. Options 'ss1', 'ss2', 'ss3', 'ss4' request the calculation of Type I, II, III, and IV sums of squares, which are relevant for unbalanced models and test different aspects of model effects.
Copied!
proc glm;
class drug disease;
model y=drug disease drug*disease / ss1 ss2 ss3 ss4;
run;
1
PROC GLM;
2
class drug disease;
3
model y=drug disease drug*disease / ss1 ss2 ss3 ss4;
4
RUN;
3 Code Block
PROC GLM
Explanation : This second PROC GLM block is similar to the previous one, reaffirming the unbalanced ANOVA model. It additionally includes the 'lsmeans drug' statement which calculates the least squares means for the 'drug' variable. The 'pdiff=all' option requests all pairwise comparisons between the levels of 'drug', and 'adjust=tukey' applies Tukey's adjustment to control the family-wise error rate during multiple comparisons, thus ensuring more robust inferences.
Copied!
proc glm;
class drug disease;
model y=drug disease drug*disease / ss1 ss2 ss3 ss4;
lsmeans drug / pdiff=all adjust=tukey;
run;
1
PROC GLM;
2
class drug disease;
3
model y=drug disease drug*disease / ss1 ss2 ss3 ss4;
4
lsmeans drug / pdiff=all adjust=tukey;
5
RUN;
4 Code Block
PROC GLM
Explanation : This third PROC GLM block activates 'ods graphics on' to generate graphics. The 'plot=meanplot(cl)' option in the 'proc glm' statement requests a mean plot with confidence intervals ('cl' for confidence limits) for the model effects. The model and least squares means ('lsmeans') are specified as before. The 'ods graphics off' statement deactivates ODS graphics after the procedure execution. This block aims to provide a visualization of model effects in addition to tabular results.
Copied!
ods graphics on;
proc glm plot=meanplot(cl);
class drug disease;
model y=drug disease drug*disease;
lsmeans drug / pdiff=all adjust=tukey;
run;
ods graphics off;
1
ods graphics on;
2
PROC GLM plot=meanplot(cl);
3
class drug disease;
4
model y=drug disease drug*disease;
5
lsmeans drug / pdiff=all adjust=tukey;
6
RUN;
7
ods graphics off;
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.