How to Select Study Participants to Include in Your Analyses
The day-level metrics that you created in previous steps will now be averaged over multiple days to produce one record per person. Only data from valid persons will be summarized. A valid person is a participant who has a sufficient number of valid days. Criteria for a valid day and a valid person can be defined by the analyst. In the sample code, a valid day is a day in which the participant wore the monitor for at least 10 hours and a valid person is a participant who has at least 4 valid days. Use the PROC SUMMARY statement to count the total number of valid days and the DATA step to identify valid persons.
Sample Code
*-------------------------------------------------------------------*;
    * Define a valid day and a valid  person.                            *;
    * NOTE:                                                             *;
    * to change the definitions  on the number of wear hours (wear_hr)   *;
    * required for a valid day, or the number  of valid days (valdays)   *;
    * required for a valid person, please  modify the statements below.  *;
    *-------------------------------------------------------------------*; 
  pam_day; 
   set  pam_perday; 
       valid_day=(wear_hr>=10 );   * assign valid  day hours criterion here *;  
   format  valid_day  yesno. ; 
   label  valid_day= '10+ hours of  wear (yes/no)' ; 
run ;  
proc summary data=pam_day;
   by  seqn; 
   var  seqn; 
   where  valid_day= 1 ; 
   output out =valid 
             n=valdays;     * number of days  with 10+ hours of wear *; 
run ;  
data pam_day;
   merge  pam_day(in=inall) valid; 
   by  seqn; 
   if  inall; 
   if  valdays= . then  valdays= 0 ; 
   label  valdays= 'Number of  days with 10+ hours of wear' ; 
   valid_person=(valdays>=4 );   * assign valid  person days criterion here *;  
   format  valid_person  yesno. ; 
   label  valid_person  =  'At  least 4 days with 10+ hours of wear (yes/no)' ; 
   drop  _freq_  _type_; 
run ;