How to Use a SAS Macro Designed to Define Periods of Monitor Wear or Non-Wear


The macros included in the program encompass many lines of code and are not presented in the text of the tutorial. We encourage you to refer closely to the program as you complete the remainder of Module 7. In addition, sorting the physical activity monitor data and running the macros may take hours and will likely require many resources from your computer. For your convenience, permanent datasets yielded from the program can be found under “Additional Resources” on the Navigation Bar to the left.

The ‘(%nw)’ macro defines the duration of monitor non-wear periods as well as wear periods within a day based on user defined minimum length of non-wear period. This step is important in defining whether the day of observation is considered as a valid day. For our analysis, a valid day is defined as having had 10 or more hours of wear-time. Later in the tutorial, we will show you how we ultimately select study participants who had 4 or more valid days, defined as 10 or more hours of wear-time per day.

A non-wear period starts at a minute with an intensity count of zero. Minutes with intensity count of zero or up to two consecutive minutes with intensity counts between 1 and 99 are considered to be valid non-wear minutes.  (The allowance for 1 to 2 minutes of counts between 1 and 99 is to account for some participants who did not take off the monitor at bed-time. It is intended to prevent sleep time being classified as wear time.) A non-wear period is established when the specified length of consecutive non-wear minutes is reached. The non-wear period stops when any of the following conditions is met:

  • 1 minute with intensity count >99, or
  • 1 minute with a missing intensity count, or
  • 3 consecutive minutes with intensity counts between 1 and 99, or
  • the last minute of the day is reached.

After categorizing each non-wear and wear period, the macro creates summary variables of wear time and non-wear time for each participant and two data sets, one with only non-wear minutes and one with only wear minutes. The wear data will be used by subsequent macros to calculate summary variables for activity of various intensities.

The number of minutes of zero intensity that define a non-wear period can be modified at the very end of the macro, after the “%mend nw;” statement, where the macro variable nwperiod is defined. In the SAS code provided, we set the number of minutes of zero intensity that define a non-wear period to 60.

After the end of macro ‘(%nw)’, a shell data set is created to define a variable that classifies each minute as wear or non-wear.