I would like to get a model to predict the dichotomous yes/no outcome (yes sleep disturbance/ no sleep disturbance) and then output that to a new dataset for each individual at each time point (is this possible?). There are many individuals that do not have all 4 time points and we would like to be able to include everyone. So far I have only been able to get the model to output means/probabilities and they are the same for each participant and each time point (or just for individuals with data at that time point). Any suggestions on what model/code I should be using? For example, if my data and model look like this:
data sleep;
input ID Months SleepDist;
cards;
1 0 1
1 10 1
1 25 0
1 39 1
2 0 1
2 10 .
2 25 1
2 39 0
3 0 1
3 10 .
3 25 0
3 39 .
4 0 1
4 10 .
4 25 0
4 39 0
5 0 1
5 10 1
5 25 1
5 39 0
6 0 0
6 10 .
6 25 0
6 39 1
;
proc genmod data= sleepdata;
class ID /missing;
model SleepDist = Months / dist=bin expected;
repeated subject=ID / type=un covb corrw;
output out = try
pred= pred;
run;
What I get:
ID | Months | SleepDist | Predicted Value |
1 | 0 | 1 | 0.164 |
1 | 10 | 1 | 0.269 |
1 | 25 | 0 | 0.485 |
1 | 39 | 1 | 0.694 |
2 | 0 | 1 | 0.164 |
2 | 10 | . | 0.269 |
2 | 25 | 1 | 0.485 |
2 | 39 | 0 | 0.694 |
3 | 0 | 1 | 0.164 |
3 | 10 | . | 0.269 |
3 | 25 | 0 | 0.485 |
3 | 39 | . | 0.694 |
...
I would like:
ID | Months | SleepDist | Predicted Value |
1 | 0 | 1 | 1 |
1 | 10 | 1 | 1 |
1 | 25 | 0 | 0 |
1 | 39 | 1 | 1 |
2 | 0 | 1 | 1 |
2 | 10 | . | 1 |
2 | 25 | 1 | 1 |
2 | 39 | 0 | 0 |
3 | 0 | 1 | 1 |
3 | 10 | . | 0 |
3 | 25 | 0 | 0 |
3 | 39 | . | 1 |
…
Thanks!
Also, be careful what probability you are modelling. For a neutral cutoff (0.5) you would be doing:
proc genmod data=sleep;
class ID;
model SleepDist(event='1') = Months / dist=bin expected;
repeated subject=ID / type=un covb corrw;
output out = sleepPred pred=pred;
run;
data sleepProb;
set sleepPred;
SleepDistPred = pred > 0.5;
run;
(event='1') tells the procedure which probability you are modelling.
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.