LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2000)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 18 Jun 2000 16:11:35 -0400
Reply-To:     Raynald Levesque <rlevesque@VIDEOTRON.CA>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Raynald Levesque <rlevesque@VIDEOTRON.CA>
Subject:      Re: difference between times?
Content-type: text/plain; charset=Windows-1252

Hi James

* Using the type of entry you give in your email. NEW FILE. DATA LIST LIST /id(F8) Sleetime(TIME5) sampm(A2) waketime(TIME5) wampm(A2). BEGIN DATA. 1 12:00 PM 11:00 AM 2 2:00 AM 10:00 AM 3 4:00 AM 1:00 PM 4 11:30 PM 12:30 PM 5 12:30 AM 12:45 PM END DATA. LIST.

* I assume sleep time of half past midnight is coded as 12:30 AM. COMPUTE timebeg=12+sleetime/3600. IF sampm='AM' AND (XDATE.HOUR(sleetime)<>12) timebeg=timebeg+12. COMPUTE timeend=24+waketime/3600. IF wampm='PM' AND (XDATE.HOUR(waketime)<>12) timeend=timeend+12. COMPUTE dur1=timeend-timebeg. * Here dur1 is a real number (10.25 means 10 hours 15 minutes) * if you want answer in HH:MM format. COMPUTE dur2=dur1*3600. FORMATS dur2(TIME5). EXECUTE.

*To increase speed of entry, I would recommend to enter 0 for AM and 1 for PM. The above syntax would have to *be changed accordingly. Note that a time like 12:30 can be entered as 12.30 instead of 12:30. The advantage of *12.30 is that it can be entered using ONLY the numeric pad, it is therefore faster to enter.

* method 2 (not really easier or better). * Here time is entered in DTIME format, in this format. * 0 21:00 means 9 PM the day before the survey. * 1 00:30 means half past midnight. * 1 01:00 means 1 AM the day of the survey. * 1 12:30 means 12:30 PM the day of the survey.

NEW FILE. DATA LIST LIST /id(F8) Sleetime(DTIME8) waketime(DTIME8). BEGIN DATA. 1 1:00:00 1:11:00 2 1:2:00 1:10:00 3 1:4:00 1:1:00 4 0:11:30 1:12:30 5 1:00:30 1:12:45 END DATA. LIST.

COMPUTE dur3=dwtime-dstime. FORMAT dur3 (TIME5). *Here dur3 is duration in hours and minutes (10:30 is 10 hours and 30 minutes). EXECUTE.

HTH Raynald Levesque rlevesque@videotron.ca

----- Original Message ----- From: James Pratt <jpratt@CYBERZONE.NET> Newsgroups: bit.listserv.spssx-l To: <SPSSX-L@LISTSERV.UGA.EDU> Sent: Saturday, June 17, 2000 6:09 PM Subject: difference between times?

> OK, two questions for any date/time calculation gurus out there. I have a > survey that asks the participant to indicate what time they went to sleep > last night and what time they woke up this morning. I want to know how long > they slept the night before they filled out the survey. > > I have a few thousand responses that have been entered into SPSS 10 in the > way the survey is laid out, which is the following: > > Case SleepTime SAMPM WakeTime WAMPM > 1 12:00 PM 11:00 AM > 2 2:00 AM 10:00 AM > 3 4:00 AM 1:00 PM > 4 11:30 PM 12:30 PM > ... > > SleepTime and WakeTime are in Date format with HH:MM formatting. SAMPM and > WAMPM are coded 1 for AM, 2 for PM. > > Question 1: Any SPSS syntax (or advice) out there to calculate the time > differences in this format? > > Question 2: What would be the best format to enter this data for ease of > calculation, keeping in mind that it is being done via cheap labor (read: > undergrad assistant)?


Back to: Top of message | Previous page | Main SPSSX-L page