Mean of multiple rows for each unique subject

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Mean of multiple rows for each unique subject

Hi All,

 

I have data for total sleep time in long format where there are several rows for each subject (somewhere between 8 and 14). Is there anyway to get an average total sleep time for each subject without having to convert the dataset to wide format? I am assuming that the code below won't work...

 

data sds4;
set sds3;
tst2=mean(tst);
run;

 

Thanks!


Accepted Solutions
Solution
‎12-10-2016 07:32 PM
SAS Super FREQ
Posts: 3,482

Re: Mean of multiple rows for each unique subject

Try 

 

proc means data=sds3;
class subjectID;

var tst;
run;

View solution in original post


All Replies
Solution
‎12-10-2016 07:32 PM
SAS Super FREQ
Posts: 3,482

Re: Mean of multiple rows for each unique subject

Try 

 

proc means data=sds3;
class subjectID;

var tst;
run;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 134 views
  • 1 like
  • 2 in conversation