I am trying to conduct a Longitudinal Data Analyses with time as a continuous variable, but it seems that for the repeated statement in proc mixed only allow categorical variables?
This is my code:
proc mixed data=daata; class subject treat ; model response = treat SOKLSCOR duration/s; repeated duration / subject=subject type=UN; run; quit;
My response is an interval variable (score, ranging from 0 to 100).
Treatment has 2 arms (nomial)
SOKLSCOR is a covariate (interval variable)
Duration is time in days
Subject is the subject ID
When I run this code, I get the following error:
NOTE: PROCEDURE MIXED used (Total process time): real time 0.00 seconds cpu time 0.00 seconds ERROR: Only class variables allowed in this effect. NOTE: The SAS System stopped processing this step because of errors.
How should I fix this where I can use time as an continious variable? The code works when using time as a categorical variable (visit 1, visit 2, visit 3..etc.), but I need to treat time as a categorical variable.
Actually, if you have the same number of times in each subject, you can just right:
repeated / subject=subject type=unr;
THat is, nothing before the "/". If you have unbalance, then you need to create another time variable. One way is to create a duplicate variable in a data set, and then specify this is a class variable in mixed.:
data daata; set daata;
time = duration;
proc mixed;
class subject treat time;
model response = treat soklscor duration / s;
repeated time / subject=subject type=unr;
run;
Actually, if you have the same number of times in each subject, you can just right:
repeated / subject=subject type=unr;
THat is, nothing before the "/". If you have unbalance, then you need to create another time variable. One way is to create a duplicate variable in a data set, and then specify this is a class variable in mixed.:
data daata; set daata;
time = duration;
proc mixed;
class subject treat time;
model response = treat soklscor duration / s;
repeated time / subject=subject type=unr;
run;
Lvm,
thanks for your response... Even though it is a continious variable, I should put the time variable in the class statement?
I think the data is unbalanced, since patients do miss visits. But I did create a record for them. So if take a look at my sample table below, Patient 3 missed his 2nd visit. Because of this, can I treat this as balanced?
And to confirm, this is ok to do where there are missing duration (since patients skip visits) and the durations varies (so for example ID=1 and ID 2 had different durations for visit 2.
For example:
ID | Visit | Duration |
1 | Visit 1 | 0 |
1 | Visit 2 | 53 |
2 | Visit 1 | 0 |
2 | Visit 2 | 40 |
3 | Visit 1 | 0 |
3 | Visit 1 | . |
Also, I seem to run into a memory issue when using "repeated time / subject=subject type=un;" It worked fine when setting the covariance structure to VC, but I need to set it to UN. Any thoughts on how to fix this?
NOTE: 438 observations are not included because of missing values. ERROR: Unable to allocate sufficient memory: a request for 1954142K bytes exceeded the 786430K available. Note that the deficit amount may not be the amount of memory needed for a successful run, since it does not reflect subsequent allocations by this or other processes. ERROR: The SAS System stopped processing this step because of insufficient memory. NOTE: PROCEDURE MIXED used (Total process time): real time 0.34 seconds cpu time 0.04 seconds
With the missing values, but there is a record for the missing value, can I cosnider my data balanced?
Hmm--do you really need to model an unstructured dataset? Depending on the number of timepoints (and missingness and spacing), you could run into an overspecified model very quickly.
One possibility is to consider a spatial power covariance structure or a splined covariance structure. There are some very good examples in the documentation for the splined structure, and the spatial power structure is a generalization of the autoregressive structure.
Steve Denham
Yeah we need to specify the the correct covariance structure. I ran it with VC as the covariance structure and the covtest indicates it is not the correct structure. So I am trying a few others hopefully.
We have baseline, 3mo, 6mo and end of study visit. But the study was ended early due to adverse events. So the end of study visit varies (some was before the 3 mo visit, which means missing 6mo visits, some subjects had the 3 mo visit and were never heard of again..etc.). this data is very messy sadly. I will look into the spatial power covariance structure or a splined covariance structure as you suggested
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.