BookmarkSubscribeRSS Feed
confooseddesi89
Quartz | Level 8

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!

 

1 REPLY 1
SteveDenham
Jade | Level 19

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

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is ANOVA?

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.

Discussion stats
  • 1 reply
  • 742 views
  • 0 likes
  • 2 in conversation