How to Create New Variables to Describe Leisure-Time Physical Activity

Study participants aged 12 years and older were asked to indicate whether they performed moderate and/or vigorous leisure-time activities at intervals of 10 minutes or more over the 30 days preceding the interview. These data are found in the PAQ dataset. Data on specific activities, frequency, and duration are found in the PAQIAF dataset.

For the PAQMSTR.sas program, we will calculate Moderate Leisure-Time MET minutes per week (MOD_LTMMPW) and Vigorous Leisure-Time MET minutes per Week (VIG_LTMMPW). We also will create Moderate Leisure-Time minutes per week (MOD_LTMINW) and Vigorous Leisure-Time minutes per Week (VIG_LTMINW).
 
 PAQ Variables and Program Notes
*  PAD320: Moderate activity over past 30 days (1 = Yes, 2 = No)
*  PAD200: Vigorous activity over past 30 days (1 = Yes, 2 = No)

 PAQIAF Variables and Program Notes
*  PADMETS: MET score for activity
*  PADTIMES: Number of times did activity in past 30 days
*  PADDURAT: Average duration of activity in minutes
*  PADLEVEL: Activity level (1 = Moderate; 2 = Vigorous)

The table below includes segments of code from the PAQMSTR.sas program.

Annotated Code for PAQMSTR.sas program
Program Description SAS Code
Leisure-time activity is reported by month. Calculate moderate and vigorous minutes and MET minutes of activity by month. We will later calculate the corresponding weekly activity. Initialize intermediate variables to ‘0’.

*monthly calculation of moderate and vigorous leisure-time activities;

  MOD_LTMINM = 0 ;
  MOD_LTMMPM = 0 ;
  VIG_LTMINM = 0 ;
  VIG_LTMMPM = 0 ;

Study participants may report multiple activities, which have pre-assigned MET scores.  For each level of activity (moderate or vigorous), multiply the frequency and duration to get a monthly sum of minutes of activity. Next, multiply the MET value of the activity against the minutes per month to get MET minutes per month for the given activity.

*moderate activities;
if PADLEVEL = 1 then do ;
  MOD_LTMINM = PADTIMES*PADDURAT;
  MOD_LTMMPM = PADMETS*MOD_LTMINM;
end ;

*vigorous activities;
else if PADLEVEL = 2 then do;
  VIG_LTMINM = PADTIMES*PADDURAT;
  VIG_LTMMPM = PADMETS*VIG_LTMINM;
end ;

run ;

For each study participant, sum the leisure-time minutes per month and the leisure-time MET minutes by combining these values for each of their leisure-time activities. Set these variables in the temporary ‘byid’ dataset.

proc means data = paqiaf noprint ;
by SEQN;
var MOD_LTMINM MOD_LTMMPM VIG_LTMINM VIG_LTMMPM;
output out = byid sum = MOD_LTMINM MOD_LTMMPM VIG_LTMINM VIG_LTMMPM;
run ;

Convert monthly summaries to weekly summaries. Use 4.33 as the average number of weeks in a month.

data byid (keep = SEQN MOD_LTMINM MOD_LTMMPM VIG_LTMINM VIG_LTMMPM MOD_LTMINW MOD_LTMMPW VIG_LTMINW VIG_LTMMPW LTMINW LTMMPW);
set byid;
by SEQN;

*change per month to per week;

  MOD_LTMINW = MOD_LTMINM/4.33 ;
  MOD_LTMMPW = MOD_LTMMPM/4.33 ;
  VIG_LTMINW = VIG_LTMINM/4.33 ;
  VIG_LTMMPW = VIG_LTMMPM/4.33 ;

*Sum leisure activity based on moderate + vigorous;

  LTMINW = MOD_LTMINW + VIG_LTMINW;
  LTMMPW = MOD_LTMMPW + VIG_LTMMPW;

*Label newly created variables;

  label MOD_LTMMPW = 'Moderate Leisure-Time MET min/wk'
        MOD_LTMINW = 'Moderate Leisure-Time min/wk'
        VIG_LTMMPW = 'Vigorous Leisure-Time MET min/wk'
        VIG_LTMINW = 'Vigorous Leisure-Time min/wk'
        LTMINW = 'Sum of MVPA Leisure-Time min/wk'
LTMMPW = 'Sum of MVPA Leisure-Time MET min/wk' ;
run ;