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 (July 2003)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 9 Jul 2003 16:35:52 -0400
Reply-To:     Richard Ristow <wrristow@mindspring.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Richard Ristow <wrristow@mindspring.com>
Subject:      Re: Time-Use Research Analysis with SPSS
In-Reply-To:  <BE3A434A142308428AB1E59E334E6E87785171@excmig2.intra.dlr.d e>
Content-Type: text/plain; charset="iso-8859-1"; format=flowed

At 03:27 PM 7/3/2003 +0200, Schmid, Hans-Peter wrote:

>I am doing a project [whose focus] is to analyse a time use-study. >Various people had to report what they were doing on two subsequent >days (their time use from midnight to midnight). For that, one day is >split into 288 five-minute-segments. In each of these 288 segments, >one of 231 activities is available. For every person [for each of two >days], there are 288 variables in the SPSS-data set, with >five-minute-segments (and with activities like sleep etc.), which define >that personīs time use over one day.

And, at 11:01 AM 7/8/2003 +0200, Schmid, Hans-Peter added by private mail:

>I tried the do repeat / count - command. And it works perfect. (See posting "Re: Time-Use Research Analysis with SPSS", Richard Ristow, Thu, 3 Jul 2003 11:48:48 -0400.)

>And yes, you guessed the next step: to get the frequencies [of each >activy code] to reduce the [number of different activity codes]. My >problem with MULT RESPONSES (Syntax) was, that it is only possible to >work out with 100 variables, my 288 are too many.

Very commonly, a data set like this is easier to analyze if it's "unrolled", with 288 cases per respondent per day, instead of one, with variables like this:

RespID - Identifier for respondent DayNum - Day (1,2) for this respondent IntNum - Number of the 5-minute interval, 1-288 Time - Time of day, an SPSS time variable giving the clock time, probably at the beginning of the interval. (Not strictly necessary, but VERY useful.) ActCode - Code for the activity for that interval

This is a very inefficient format for storage, with four key values stored for each data value, but it allows you to do overall activity frequencies with a simple FREQUENCIES; and to get frequencies separately by respondent, by intervals of the day, etc. You could easily SPLIT FILES or CROSSTAB by person, to get the frequencies you would use DO REPEAT/COUNT for.

Restructuring is probably easiest in 11.5.x, where VARSTOCASES should do it directly, but it's pretty easy with VECTOR, LOOP and XSAVE in earlier versions:

/* CODE NOT TESTED. */ /* Assumptions: */ /* - RespId is respondent identifier in the file */ /* - DayNum is respondent day, 1 or 2 */ /* - The 288 activity codes are in variables */ /* SEG001 to SEG288, *which are contiguous in */ /* the file* so VECTOR may be used. */ /* - Input is the SPSS working file */ /* - Output to c:\MY_SPSS\TimeUse.SAV */

VECTOR SEGMENTS = SEG001 TO SEG288.

NUMERIC IntNum (F3) /Time (TIME5) /ActCode(F3). VARIABLE LABELS IntNum 'Number of 5-minute interval, 1-288' Time 'Time of day at start of interval' ActCode 'Activity code for interval'. VALUE LABELS ActCode <<Strongly recommended, but there are 231 of them>>.

LOOP IntNum = 1 TO 288. . COMPUTE TIME = TIME.HMS(0,5*(IntNum-1)). . COMPUTE ActCode = SEGMENTS(IntNum). . XSAVE OUTFILE='c:\MY_SPSS\TimeUse.SAV' /KEEP=RespId DayNum IntNum Time ActCode. END LOOP. EXECUTE.

This use of function "TIME.HMS", to convert interval number to time, is a little "cute", and it's not obvious that it should work that way. From the release 9 syntax manual, p. 61; see especially the second full paragraph:

"TIME.HMS(h,m,s) Combine hour, minute, and second into a time interval. For example, the command . COMPUTE PERIOD1= TIME.HMS (HR,MIN,SEC). produces an interval of 45,030 seconds for PERIOD1 when HR equals 12, MIN equals 30, and SEC equals 30. The value can be displayed as 12:30:30 with a TIME8 print format.

"You can supply one, two, or three arguments. Trailing arguments can be omitted and default to 0. The value of the first nonzero argument can spill over into the next higher argument. For example, the command. . COMPUTE PERIOD2=TIME.HMS(HR,MIN). produces an interval of 5400 seconds for PERIOD2 when HR is 0 and MIN is 90. The value can be displayed as 01:30 with a TIME5 print format."


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