The script first creates a 'DrugTest' dataset containing the effect of three drugs (A, D, F). Then, it uses PROC GLM to model the effect of the drug and the pre-treatment measurement on the post-treatment measurement. Least squares means (lsmeans) are calculated to compare the effects of the drugs and are saved in the 'adjmeans' table, which is then displayed. Finally, the script uses ODS Graphics and a second PROC GLM pass to visualize the adjusted covariance analysis model, including a graph of means with confidence limits.
Data Analysis
Type : CREATION_INTERNE
The data is created directly within the script using a DATA step and 'datalines'.
1 Code Block
DATA STEP Data
Explanation : This block creates the 'DrugTest' dataset by reading embedded data via 'datalines'. It defines three variables: 'Drug' (character), 'PreTreatment' (numeric), and 'PostTreatment' (numeric).
Copied!
data DrugTest;
input Drug $ PreTreatment PostTreatment;
datalines;
A 11 6 A 8 0 A 5 2 A 14 8 A 19 11
A 6 4 A 10 13 A 6 1 A 11 8 A 3 0
D 6 0 D 6 2 D 7 3 D 8 1 D 18 18
D 8 4 D 19 14 D 8 9 D 5 1 D 15 9
F 16 13 F 13 10 F 11 18 F 9 5 F 21 23
F 16 12 F 12 5 F 12 16 F 7 1 F 12 20
;
run;
1
DATA DrugTest;
2
INPUT Drug $ PreTreatment PostTreatment;
3
DATALINES;
4
A 116 A 8 0 A 52 A 148 A 1911
5
A 64 A 1013 A 61 A 118 A 3 0
6
D 6 0 D 62 D 73 D 81 D 1818
7
D 84 D 1914 D 89 D 51 D 159
8
F 1613 F 1310 F 1118 F 95 F 2123
9
F 1612 F 125 F 1216 F 71 F 1220
10
;
11
RUN;
2 Code Block
PROC GLM Data
Explanation : This General Linear Model (GLM) procedure performs a covariance analysis. 'PostTreatment' is the dependent variable, modeled by the effect of 'Drug' (class variable) and 'PreTreatment' (covariate). The 'solution' option requests the display of parameter estimates. The 'lsmeans' statement calculates the adjusted means for each 'Drug' level, with standard errors, p-values for differences, the covariance matrix, and saves the results to a new dataset named 'adjmeans'.
Copied!
proc glm data=DrugTest;
class Drug;
model PostTreatment = Drug PreTreatment / solution;
lsmeans Drug / stderr pdiff cov out=adjmeans;
run;
1
PROC GLMDATA=DrugTest;
2
class Drug;
3
model PostTreatment = Drug PreTreatment / solution;
4
lsmeans Drug / stderr pdiff cov out=adjmeans;
5
RUN;
3 Code Block
PROC PRINT
Explanation : This code block displays the content of the 'adjmeans' dataset, which was created by the 'lsmeans' statement in the previous PROC GLM step.
Copied!
proc print data=adjmeans;
run;
1
PROC PRINTDATA=adjmeans;
2
RUN;
4 Code Block
PROC GLM
Explanation : This block activates ODS graphics output to visualize the results. The GLM procedure is called again, this time with the 'plot=meanplot(cl)' option to generate a graph of adjusted means with confidence limits for the 'Drug' variable. The 'lsmeans' statement with the 'pdiff' option calculates pairwise differences between least squares means. ODS Graphics is then deactivated.
Copied!
ods graphics on;
proc glm data=DrugTest plot=meanplot(cl);
class Drug;
model PostTreatment = Drug PreTreatment;
lsmeans Drug / pdiff;
run;
ods graphics off;
1
ods graphics on;
2
3
PROC GLMDATA=DrugTest plot=meanplot(cl);
4
class Drug;
5
model PostTreatment = Drug PreTreatment;
6
lsmeans Drug / pdiff;
7
RUN;
8
9
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.