The script begins by creating a dataset named 'rc' via a DATA step with in-line data (datalines). This data simulates a pharmaceutical stability study with batches (Batch) and measurements (Y) taken at different months (Month). Subsequently, two MIXED procedures are executed. The first fits a linear regression model with random coefficients (intercept and 'Month' slope) for each batch. The second explores a model variation by including an additional class variable 'Monthc'.
Data Analysis
Type : CREATION_INTERNE
The data is generated directly within the script using a DATA step and DATALINES statement. The 'rc' dataset is created in memory for the SAS session.
1 Code Block
DATA STEP Data
Explanation : This DATA block creates the 'rc' table. It reads the 'Batch' and 'Month' variables, then uses a 'do' loop to read up to 6 'Y' values for each initial record. For each 'Y' value read, a new observation is generated. The 'Monthc' variable is created as a copy of 'Month'. Data is provided in-line via 'datalines'.
Explanation : This procedure fits a mixed model to the 'rc' data. 'Batch' is defined as a classification variable. The 'model' statement specifies 'Y' as the dependent variable and 'Month' as a fixed effect. The 'random' statement defines random intercept ('Int') and slope ('Month') for each 'Batch' level, with an unstructured covariance structure ('type=un'). The 's' option requests the display of solutions for fixed and random effects.
Copied!
proc mixed data=rc;
class Batch;
model Y = Month / s;
random Int Month / type=un sub=Batch s;
run;
1
PROC MIXEDDATA=rc;
2
class Batch;
3
model Y = Month / s;
4
random Int Month / type=un sub=Batch s;
5
RUN;
3 Code Block
PROC MIXED
Explanation : A second PROC MIXED analysis is performed, adding 'Monthc' to the list of classification variables. The fixed model remains the same. The 'random' statement is modified to include 'Monthc' as a random effect in addition to the intercept and 'Month', still grouped by 'Batch'. This allows exploring a different random model structure.
Copied!
proc mixed data=rc;
class Batch Monthc;
model Y = Month / s;
random Int Month Monthc / sub=Batch s;
run;
1
PROC MIXEDDATA=rc;
2
class Batch Monthc;
3
model Y = Month / s;
4
random Int Month Monthc / sub=Batch s;
5
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.
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.