Hello,
I have some experience with SAS, but I'm struggling with the proper code for my intended analyses with my given study design. To summarize, multiple nights of sleep data were collected per person across time ("date"). There is a specific event (occurring at the same date for everyone), from which "days from event" is calculated. Below are some sample data:
subject | date | sleep | Sex | Days from Event |
1 | 10/1/2021 | 6 | M | -27 |
1 | 10/3/2021 | 5 | M | -25 |
1 | 10/4/2021 | 8 | M | -24 |
1 | 10/5/2021 | 5 | M | -23 |
2 | 10/3/2021 | 4 | F | -25 |
2 | 10/5/2021 | 4 | F | -23 |
2 | 10/6/2021 | 9 | F | -22 |
3 | 10/3/2021 | 8 | M | -25 |
3 | 10/4/2021 | 4 | M | -24 |
3 | 10/5/2021 | 6 | M | -23 |
3 | 10/6/2021 | 7 | M | -22 |
3 | 10/7/2021 | 9 | M | -21 |
As you can see, not every person has every "date" time point. The number of provided days also varies per person.
I want to examine whether sleep changed across time within each person, with "days from event" as a linear predictor of sleep, and a random intercept (for each subject). I also want to examine whether sex moderates this association (which is easy enough with an interaction term in the model statement). However, I'm not sure if I should use a repeated OR a random statement; and/or whether I should nest the day within the subject (and if so, how to do that). Any assistance you have is welcome.
Also, please let me know if you need more information. For data privacy reasons, I'd prefer to provide minimal information, but I understand this may make it difficult to assist me. Thanks!
Start out with
repeated /subject=day(subject);
and see what you get. I know that seems overly simple, but at this point, you probably need something that should work where you can look at results to see if you have adequately captured what is going on.
SteveDenham
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.