Time calculation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Time calculation

Le, Man Minh
Hi SPSS list:



I have a data set like this:



User                 Computer          Event                Time (in
minute)



Aba1                 DL1004             LOGOFF           16-FEB-2006
16:33

Aba1                 DL1004             LOGON             16-FEB-2006
16:01

Aba1                 DL1140             LOGOFF           28-MAR-2006
09:11

Aba1                 DL1140             LOGON             28-MAR-2006
07:01

Aba1                 DL1170             LOGOFF           20-MAR-2006
10:11 (USER DID NOT LOGOFF, JUST TURN OFF COMPUTER)

Bar1                 KK1140             LOGOF             15-MAR-2006
13:01

Bar1                 KK1140             LOGON             15-MAR-2006
12:00

Bar1                 KK1000             LOGOF             18-MAR-2006
14:00

Bar1                 KK1000             LOGON             18-MAR-2006
11:00

......

......



We have around 400k records in .txt format (I changed it into SPSS file
format already) to record student logon/logoff the computing system in
around 3 months.

I arranged the log file by username. I want to find out the difference
in time between LOGON/LOGOFF (either in minute or in hour) of each
student.

This means the Time in event =LOGON subtracts Time in event = LOGOFF
(computation between 2 consecutive records)

As this data file is generated by system as log file. I can't do
anything to change the output or restructure it.





I mean while user and computer are the same if  event is LOGOFF,
calculate TimeDifference (new variable) is equal to Time(Event = log
off) - Time(event = log on).

New variable Timedifference will be put in the same record as event (
LOGOFF)



Can you help me out with the syntax and check if anything wrong in this
logic.





Man Le



215 19th St., Apt. 6

Huntington, WV 25703
Reply | Threaded
Open this post in threaded view
|

Re: Time calculation

emaguin
Man,

Your description is not completely clear to me but i think what you want to
do is compute the interval between logon and logoff for each user. There is
really two ways to go at this problem. It would be good to understand both
so that you have more flexibility.

One way it to restrucure the file from 'long' to 'wide' using the
Casestovars command. Using it is pretty easy and you can read up on it.
Then subtract the relevant columns.

The other way is to to use the lag command. I'll assume you have your file
sorted correctly (logoff follows logon) and that User uniquely identifes a
person usage at any point in time--meaning that somebody can't be logged on
to two computers at the same time.

Compute interval=-9.
if (user eq lag(user)) interval=time-lag(time).
missing values interval(-9).

When you do a frequencies you should get a count of 'x' records with a
value of -9 (and marked as missing) and 'x' records with a value greater
than 0. Your total file size is 2x.

Gene Maguin