We use cookies and other tools to enhance your experience on our website and to analyze our web traffic.
For more information about these cookies and the data collected, please refer to our Privacy Policy.

Variables of the CFT dataset

5 posts
Was this reply useful? Learn more...
 
[-]
kelseygonring +0 points · over 8 years ago

I am curious if the dataset contains two variables: family healthy history and school start time of the child/adolescent.

442 posts
bio
Was this reply useful? Learn more...
 
[-]
mrueschman +0 points · over 8 years ago

Are you asking about the Cleveland Family Study (CFS) dataset? I was looking through the CFS variables and did not see a school start time variable.

As for family health history, some of this could be ascertained from the medical history variables and a variable like familyi, which is an identifier for family units.

Let me know if I can help with any other questions!

5 posts
Was this reply useful? Learn more...
 
[-]
kelseygonring +0 points · over 8 years ago

Thank you for your response! Yes, I am asking about the Cleveland Family Study. Another question, I see that there are computed midsleep times for weekends and weekdays in the dataset. Do these calculations take into account sleep duration from the previous week?

442 posts
bio
Was this reply useful? Learn more...
 
[-]
mrueschman +0 points · over 8 years ago

It looks like these midsleep times were likely calculated from questions on the Baseline Lab Adult-Child Questionnaire (page 7, question 43). Those questions asked for average times (over the past month) that the participant went to bed and woke up on both weekdays and weekends.

5 posts
Was this reply useful? Learn more...
 
[-]
kelseygonring +0 points · over 8 years ago

I calculated sleep duration using the bedtime and waketime provided but my calculations are different than the sleep duration calculated in the dataset. Do you know how "DAYSLP_dur_hr" was calculated?

442 posts
bio
Was this reply useful? Learn more...
 
[-]
mrueschman +0 points · over 8 years ago

I dug through the archives and found some SAS code from long ago. I went ahead and tried the below against the CFS dataset here on the NSRR and was able to replicate dayslp_dur_hr and other related variables. At a glance, in comparing with daybed and daywake, the results look correct.

There was a manual correction as well to one of the weekend times -- I left that out of the code snippet.

If you continue to encounter differences and find that the dayslp_dur_hr values do not correctly line up with the component variables, please let us know and we can look to make dataset corrections. Thanks!

SAS macros:

* macro to create time variables from 24-hour times collected as integers;
%macro fixtimes(varin,varout);
        if &varin >=0 then do;
                 &varin.c = trim(left(put(&varin, 8. )));
                 &varout = input(substr(trim(left(reverse(substr(trim(left(reverse(&varin.c)!! '0000' )), 1 , 4 )))), 1 , 2 )
                                   !! ':' !! substr(trim(left(reverse(substr(trim(left(reverse(&varin.c)!! '0000' )), 1 , 4 )))), 3 , 2 ), time5. );
        end;
        format &varout time5. ;
        drop &varin.c;
%mend ;

Transformation code:

*******************************************************************************;
    * SELF-REPORTED SLEEP TIME
    *******************************************************************************;
        * FIX SELF-REPORTED BED AND WAKE TIMES (WEEKDAYS);
        %fixtimes(DAYBED ,DAYSLP_time);
        %fixtimes(DAYWAKE ,DAYWAKE_time);

         * if slptime before midnight and waketime after midnight set date as previous day;
         if hour(DAYSLP_time) > 12 and hour(DAYWAKE_time) <=12 then DAYSLP_time2 = dhms(date()- 1 ,hour(DAYSLP_time),minute(DAYSLP_time), 0 );
         * if both slptime  and waketime before midnight then use current day;
         else if hour(DAYSLP_time) > 12 and hour(DAYWAKE_time) >12 then DAYSLP_time2 = dhms(date() ,hour(DAYSLP_time),minute(DAYSLP_time), 0 );
         * otherwise use current day;
         else DAYSLP_time2 = dhms(date(),hour(DAYSLP_time),minute(DAYSLP_time), 0 );

         * if   waketime at midnight then waketime use next day;
         if  hour(DAYWAKE_time) =0 then DAYSLP_time2 = dhms(date()+1 ,hour(DAYSLP_time),minute(DAYSLP_time), 0 );
         * otherwise use current day for waketime;
         else DAYWAKE_time2 = dhms(date(),hour(DAYWAKE_time),minute(DAYWAKE_time), 0 );

        * calculate midpoint of bed and wake times;
         DAYMID_time2 = DAYSLP_time2 + (DAYWAKE_time2 - DAYSLP_time2)/2;
         DAYMID_time = timepart(DAYMID_time2);

        format daymid_time time5. DAYSLP_time2 DAYWAKE_time2 DAYMID_time2 datetime16.;

         * calculate time in bed as difference between wake and bed time (accounting for change in midnight);
         DAYSLP_dur_mn  = (DAYWAKE_time2 - DAYSLP_time2)/ 60;
         DAYSLP_dur_hr2  = (DAYWAKE_time2 - DAYSLP_time2)/ 3600;
         Label    DAYSLP_dur_mn  ='calculated sleep duration (minutes) during weekday-by DAYWAKE -DAYSLP '
                  DAYSLP_dur_hr  ='calculated sleep duration (hourss) during weekday -by DAYWAKE -DAYSLP ';

        drop daywake_time2 dayslp_time2 daymid_time2;
        *****************************************************************************************************************;

        * FIX SELF-REPORTED BED AND WAKE TIMES (WEEKENDS);
        %fixtimes(ENDBED ,ENDSLP_time);
        %fixtimes(ENDWAKE ,ENDWAKE_time);

         * if slptime before midnight and waketime after midnight, set date as previous day;
         if hour(ENDSLP_time) > 12 and hour(ENDWAKE_time) <=12 then ENDSLP_time2 = dhms(date()- 1 ,hour(ENDSLP_time),minute(ENDSLP_time), 0 );
         * if both slptime  and waketime before midnight then use current day;
         else if hour(ENDSLP_time) > 12 and hour(ENDWAKE_time) >12 then ENDSLP_time2 = dhms(date() ,hour(ENDSLP_time),minute(ENDSLP_time), 0 );
         * otherwise use current day;
         else ENDSLP_time2 = dhms(date(),hour(ENDSLP_time),minute(ENDSLP_time), 0 );

         * if waketime at midnight then waketime use next day;
         if  hour(ENDWAKE_time) =0 then ENDWAKE_time2 = dhms(date()+1,hour(ENDWAKE_time),minute(ENDWAKE_time), 0 );
         * otherwise use current day for  wake time;
         else ENDWAKE_time2 = dhms(date(),hour(ENDWAKE_time),minute(ENDWAKE_time), 0 );
         *manual fix for this one (otherwise end_dur_hr is negative);
         if  obf_pptid = 802529 then ENDWAKE_time2 = dhms(date()+1,hour(ENDWAKE_time),minute(ENDWAKE_time), 0 );

        * calculate midpoint of bed and wake times;
         ENDMID_time2 = ENDSLP_time2 + (ENDWAKE_time2 - ENDSLP_time2)/2;
         ENDMID_time = timepart(ENDMID_time2);

         format ENDmid_time time5. ENDSLP_time2 ENDWAKE_time2 ENDMID_time2 datetime16.;

         * calculate time in bed as difference between wake and bed time (accounting for change in midnight);
         END_dur_mn  = (ENDWAKE_time2 - ENDSLP_time2)/ 60;
         END_dur_hr  = (ENDWAKE_time2 - ENDSLP_time2)/ 3600;
         Label    END_dur_mn  ='calculated sleep duration (minutes) during weekend -by ENDWAKE  - ENDSLP '
                  END_dur_hr  ='calculated sleep duration (hourss) during weekend-by ENDWAKE  - ENDSLP ';

        drop endwake_time2 endslp_time2 endmid_time2;
        *****************************************************************************************************************;
5 posts
Was this reply useful? Learn more...
 
[-]
kelseygonring +0 points · over 8 years ago

This is extremely helpful, thank you for posting this syntax! Quick questions - you mentioned that a manual correction was made to the weekend sleep duration, what was the manual correction for?

442 posts
bio
Was this reply useful? Learn more...
 
[-]
mrueschman +0 points · over 8 years ago

I guess I didn't remove the correction from the code. It was this snippet (I corrected the identifier link to use our obfuscated ID):

*manual fix for this one (otherwise end_dur_hr is negative);
         if  obf_pptid = 802529 then ENDWAKE_time2 = dhms(date()+1,hour(ENDWAKE_time),minute(ENDWAKE_time), 0 );

I didn't attempt to run everything without the manual fix to see if the result is indeed negative for this subject.

5 posts
Was this reply useful? Learn more...
 
[-]
kelseygonring +0 points · over 8 years ago

We calculated the sleep duration of weekday sleep and weekend sleep and when compared to the databases calculations, the weekday sleep duration (DAYSLP_dur_hr) was the same but the weekend sleep duration (END_dur_hr) was slightly off. I was looking through the SAS code you sent (I'm not very familiar with this system) and the only inconsistency that I thought that might have affected your calculation was that ENDSLP_time below should read ENDBED_time. Thoughts? I can pass along our syntax if that would be helpful.

  • FIX SELF-REPORTED BED AND WAKE TIMES (WEEKENDS); %fixtimes(ENDBED ,ENDSLP_time); %fixtimes(ENDWAKE ,ENDWAKE_time);
442 posts
bio
Was this reply useful? Learn more...
 
[-]
mrueschman +0 points · over 8 years ago

Kelsey,

Sure, if you could pass along the syntax that would be helpful. You can send it to me at mrueschman@bwh.harvard.edu.

Did you do any manual checks to see which of the weekend sleep duration values (ones generated with code above or ones with your code) seemed objectively "right" (based on the component variables)?

I should have a chance in the next week or so to dive in deeper and explore the issue myself. Thanks for keeping us updated!