1 The SAS System 11:05 Tuesday, March 13, 2007 NOTE: Copyright (c) 1999-2001 by SAS Institute Inc., Cary, NC, USA. NOTE: SAS (r) Proprietary Software Release 8.2 (TS2M0) Licensed to NATIONAL INSTITUTES OF HEALTH, Site 0040679003. NOTE: This session is executing on the WIN_PRO platform. NOTE: SAS initialization used: real time 0.53 seconds cpu time 0.12 seconds NOTE: AUTOEXEC processing beginning; file is C:\Program Files\SAS Institute\SAS\V9.1\autoexec.sas. NOTE: Libref GDEVICE0 was successfully assigned as follows: Engine: V8 Physical Name: C:\Documents and Settings\DoddK\My Documents\SASGRAPH NOTE: AUTOEXEC processing completed. 1 *------------------------------------------------------------------------------------ 1 ! ------*; 2 *create.pam_perperson.sas 2 ! *; 3 * 3 ! *; 4 *Purpose: summarize valid PAM data into one record per person, add demographic 4 ! variables, *; 5 * and output to a SAS transport data set. 5 ! *; 6 * A valid day is a day in which the subject wore the monitor for 10+ hours. 6 ! *; 7 * A valid person is a person with 4+ valid days. 7 ! *; 8 * Please see comments below on how to change the definitions of valid day and valid 8 ! person.*; 9 * 9 ! *; 10 *Before running the code below: 10 ! *; 11 *1. Modify the libname statement to refer to the folder where you want to store the 11 ! input *; 12 * and output datasets. 12 ! *; 13 *2. Create a SAS dataset named DEMO_C in that folder from the Demographics data from 13 ! *; 14 * http://www.cdc.gov/nchs/about/major/nhanes/nhanes2003-2004/demo03_04.htm. 14 ! *; 15 *3. Run create.pam_perday.sas to create the dataset pam_perday, and save it in that 15 ! folder.*; 16 *4. Save PAM_formats.txt (included with these programs) and list the full path in the 16 ! *; 2 The SAS System 11:05 Tuesday, March 13, 2007 17 * %include statement below. You will need to include these formats in any program 17 ! that *; 18 * uses the output dataset. 18 ! *; 19 *------------------------------------------------------------------------------------ 19 ! ------*; 20 title 'PAM Processing '; 21 libname myfolder "&home/EATS_NHANES/sasdata"; NOTE: Libref MYFOLDER was successfully assigned as follows: Engine: V8 Physical Name: C:\Documents and Settings\DoddK\My Documents\EATS_NHANES\sasdata 22 libname demo xport "&home/EATS_NHANES/sasdata/demo_c.xpt"; NOTE: Libref DEMO was successfully assigned as follows: Engine: XPORT Physical Name: C:\Documents and Settings\DoddK\My Documents\EATS_NHANES\sasdata\demo_c.xpt 22 ! * Added by kwd; 23 %include "&home/EATS_NHANES/sasprog/AccelerometryPA/PAM_formats.sas"; NOTE: Format YESNO has been output. NOTE: Format WKDAY has been output. NOTE: Format GENDER has been output. NOTE: Format AGEGRP has been output. NOTE: PROCEDURE FORMAT used: real time 0.14 seconds cpu time 0.00 seconds 58 59 *----------------------------------------------------------------------*; 60 *Define a valid day and a valid person. *; 61 *NOTE: to change the definitions on the number of wear hours(wear_hr) *; 62 * required for a valid day, or the number of valid days(valdays) *; 63 * required for a valid person, please modify the statements below.*; 64 *----------------------------------------------------------------------*; 65 data pam_day; 66 set myfolder.pam_perday; 67 valid_day=(wear_hr>=10); /*change valid day hours criterion here*/ 68 format valid_day yesno.; 69 label valid_day='10+ hours of wear (yes/no)'; 70 run; NOTE: There were 47771 observations read from the data set MYFOLDER.PAM_PERDAY. NOTE: The data set WORK.PAM_DAY has 47771 observations and 16 variables. NOTE: DATA statement used: real time 0.23 seconds cpu time 0.03 seconds 71 72 proc summary data=pam_day; 73 by seqn; 74 var seqn; 75 where valid_day=1; 3 The SAS System 11:05 Tuesday, March 13, 2007 76 output out=valid 77 n=valdays; /*number of days with 10+ hours of wear*/ 78 run; NOTE: There were 31667 observations read from the data set WORK.PAM_DAY. WHERE valid_day=1; NOTE: The data set WORK.VALID has 6329 observations and 4 variables. NOTE: PROCEDURE SUMMARY used: real time 0.32 seconds cpu time 0.03 seconds 79 80 data pam_day; 81 merge pam_day(in=inall) valid; 82 by seqn; 83 if inall; 84 85 if valdays=. then valdays=0; 86 label valdays='Number of days with 10+ hours of wear'; 87 88 valid_person=(valdays>=4); /*change valid person days criterion here*/ 89 format valid_person yesno.; 90 label valid_person = 'At least 4 days with 10+ hours of wear (yes/no)'; 91 92 drop _freq_ _type_; 93 94 run; NOTE: There were 47771 observations read from the data set WORK.PAM_DAY. NOTE: There were 6329 observations read from the data set WORK.VALID. NOTE: The data set WORK.PAM_DAY has 47771 observations and 18 variables. NOTE: DATA statement used: real time 0.07 seconds cpu time 0.07 seconds 95 96 *------------------------------------------------------------------------------------ 96 ! -------*; 97 *Summarize for valid people(4+ valid days), using only their valid days(10+ hrs of 97 ! wear). *; 98 *------------------------------------------------------------------------------------ 98 ! -------*; 99 proc summary data=pam_day; 100 by seqn; 101 where valid_person=1 and valid_day=1; 102 var tot_dur_mv tot_dur_mv1 103 tot_dur_m tot_dur_m1 104 tot_dur_v tot_dur_v1 105 tot_min_wr tot_cnt_wr; 106 output out=valid_days 107 mean(tot_dur_mv tot_dur_mv1 4 The SAS System 11:05 Tuesday, March 13, 2007 108 tot_dur_m tot_dur_m1 109 tot_dur_v tot_dur_v1 110 tot_min_wr)= 111 allmean_mv allmean_mv1 /*mean duration of mod./vig. activity bouts*/ 112 allmean_m allmean_m1 /*mean duration of mod. activity bouts*/ 113 allmean_v allmean_v1 /*mean duration of vig. activity bouts*/ 114 allmean_min_wr /*mean wear time(minutes)*/ 115 sum(tot_min_wr tot_cnt_wr)=all_min_wr all_cnt_wr; /*total wear minutes and 115 ! intensity counts*/ 116 run; NOTE: There were 28601 observations read from the data set WORK.PAM_DAY. WHERE (valid_person=1) and (valid_day=1); NOTE: The data set WORK.VALID_DAYS has 4866 observations and 12 variables. NOTE: PROCEDURE SUMMARY used: real time 0.06 seconds cpu time 0.04 seconds 117 118 data valid_days; 119 set valid_days; 120 allmean_cnt_wr=all_cnt_wr/all_min_wr; /*mean intensity counts per minute*/ 121 allmean_hr_wr=allmean_min_wr/60; /*mean wear time(hr)*/ 122 label 123 allmean_cnt_wr='Mean intensity count per minute on wear periods from all valid 123 ! days' 124 allmean_hr_wr='Mean wear time(hr) per day from all valid days' 125 allmean_mv='Mean duration (minutes) of moderate and vigorous activity bouts (8 out 125 ! of 10 minute bouts) per day from all valid days' 126 allmean_m='Mean duration (minutes) of moderate activity bouts (8 out of 10 minute 126 ! bouts) per day from all valid days' 127 allmean_v='Mean duration (minutes) of vigorous activity bouts (8 out of 10 minute 127 ! bouts) per day from all valid days' 128 allmean_mv1='Mean duration (minutes) of moderate and vigorous activity bouts 128 ! (minimum 1 minute bouts) per day from all valid days' 129 allmean_m1='Mean duration (minutes) of moderate activity bouts (minimum 1 minute 129 ! bouts) per day from all valid days' 130 allmean_v1='Mean duration (minutes) of vigorous activity bouts (minimum 1 minute 130 ! bouts) per day from all valid days'; 131 132 drop _type_ _freq_ allmean_min_wr; 133 run; NOTE: There were 4866 observations read from the data set WORK.VALID_DAYS. NOTE: The data set WORK.VALID_DAYS has 4866 observations and 11 variables. NOTE: DATA statement used: real time 0.01 seconds cpu time 0.01 seconds 134 135 /*everyone in the analysis*/ 5 The SAS System 11:05 Tuesday, March 13, 2007 136 proc sort nodupkey data=pam_day out=pam_all; 137 by seqn; 138 run; NOTE: 40941 observations with duplicate key values were deleted. NOTE: There were 47771 observations read from the data set WORK.PAM_DAY. NOTE: The data set WORK.PAM_ALL has 6830 observations and 18 variables. NOTE: PROCEDURE SORT used: real time 0.09 seconds cpu time 0.07 seconds 139 140 /*merge with the valid day data and demographic data for final data set*/ 141 data pam_perperson; 142 merge pam_all(in=in_pam keep=seqn valid_person valdays) demo.demo_c(in=in_demog) 142 ! valid_days;* changed by kwd; 143 by seqn; 144 if in_pam; 145 if not in_demog then put 'error: not in demog' seqn=; 146 147 /*Age groups*/ 148 if 6<=ridageyr<=11 then agegrp=1; 149 else if 12<=ridageyr<=15 then agegrp=2; 150 else if 16<=ridageyr<=19 then agegrp=3; 151 else if 20<=ridageyr<=29 then agegrp=4; 152 else if 30<=ridageyr<=39 then agegrp=5; 153 else if 40<=ridageyr<=49 then agegrp=6; 154 else if 50<=ridageyr<=59 then agegrp=7; 155 else if 60<=ridageyr<=69 then agegrp=8; 156 else if ridageyr>=70 then agegrp=9; 157 format agegrp agegrp.; 158 label agegrp='Age group' ; 159 160 /*Gender*/ 161 format riagendr gender.; 162 label riagendr='Gender'; 163 164 keep seqn valid_person valdays riagendr agegrp ridageyr sdmvstra sdmvpsu wtmec2yr 165 allmean_mv allmean_mv1 allmean_m allmean_m1 allmean_v allmean_v1 165 ! allmean_cnt_wr allmean_hr_wr; 166 run; NOTE: There were 6830 observations read from the data set WORK.PAM_ALL. NOTE: There were 10122 observations read from the data set DEMO.DEMO_C. NOTE: There were 4866 observations read from the data set WORK.VALID_DAYS. NOTE: The data set WORK.PAM_PERPERSON has 6830 observations and 17 variables. NOTE: DATA statement used: real time 0.23 seconds cpu time 0.06 seconds 167 6 The SAS System 11:05 Tuesday, March 13, 2007 168 data myfolder.pam_perperson; 169 set pam_perperson; 170 run; NOTE: There were 6830 observations read from the data set WORK.PAM_PERPERSON. NOTE: The data set MYFOLDER.PAM_PERPERSON has 6830 observations and 17 variables. NOTE: DATA statement used: real time 0.04 seconds cpu time 0.03 seconds 171 172 proc contents data=myfolder.pam_perperson; 173 run; NOTE: PROCEDURE CONTENTS used: real time 0.01 seconds cpu time 0.01 seconds NOTE: The PROCEDURE CONTENTS printed pages 1-2. 174 175 *-------------------------------------------------------------------------*; 176 *You have now created the dataset with one record per person. It may be *; 177 *used in person level analysis for the PAM data. *; 178 *-------------------------------------------------------------------------*; 179 NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 NOTE: The SAS System used: real time 2.88 seconds cpu time 0.53 seconds