Hi,
I am running into a seemingly simple problem I cannot figure out so far. In short, my data looks like this: ID ev time 1 0 0 1 0 10 1 1 20 1 1 30 1 1 40 1 0 50 1 0 60 1 0 70 1 1 80 1 1 90 etc. 2 0 0 2 0 10 2 1 20 2 1 30 2 1 40 2 0 50 etc. 'ID' is a picture ID 'ev' is eyefixation (yes, no) 'time' is a consecutive run time (in ms). What I need to extract are two tings: First I need a number that depicts first, second third _consecutive_ eyefixations for each pic ID. That is some sort of counter that goes through variable 'ev' and creates a new variable that gives a '1' to the first set of consecutive cases in which ev = 1, a '2' to the second set, and so on. So, for this example, the counter would be '0' for the first 2 cases of ID 1, '1' for cases 3-5, '0' for cases 6-8, and '2' for cases 9-10 and so on. If that were possible, I would then like to calculate the fixation times for each distinct block consecutive fixations. So, how long did people look at the picture when they first looked, and thereafter. For Id 1, the first block of time would be 30 ms (cases 2-5), the second block of time would be 20 ms (cases 9-10); for ID it would be 30 ms (cases 3-5). Does someone have any idea on how/if this is possible..??? Thanks in advance for any help! ~Esther ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
I think this yields what you want. Does it? Gene Maguin
data list list / ID ev time. begin data 1 0 0 1 0 10 1 1 20 1 1 30 1 1 40 1 0 50 1 0 60 1 0 70 1 1 80 1 1 90 2 0 0 2 0 10 2 1 20 2 1 30 2 1 40 2 0 50 end data. Compute efcount=0. Do if (id eq lag(id)). If (ev eq 1) efcount=lag(efcount)+1. If (ev eq 0) efcount=lag(efcount). End if. execute. Aggregate outfile=* mode=addvariables/break= id efcount/fixtime=sum(time). format ID ev(f1.0) time efcount(f2.0) fixtime(f3.0). list id ev time efcount fixtime. ID ev time efcount fixtime 1 0 0 0 10 1 0 10 0 10 1 1 20 1 20 1 1 30 2 30 1 1 40 3 220 1 0 50 3 220 1 0 60 3 220 1 0 70 3 220 1 1 80 4 80 1 1 90 5 90 2 0 0 0 10 2 0 10 0 10 2 1 20 1 20 2 1 30 2 30 2 1 40 3 90 2 0 50 3 90 Number of cases read: 16 Number of cases listed: 16 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Esther Fujiwara Sent: Saturday, January 25, 2014 2:15 PM To: [hidden email] Subject: Calculate time/event type across cases Hi, I am running into a seemingly simple problem I cannot figure out so far. In short, my data looks like this: ID ev time 1 0 0 1 0 10 1 1 20 1 1 30 1 1 40 1 0 50 1 0 60 1 0 70 1 1 80 1 1 90 etc. 2 0 0 2 0 10 2 1 20 2 1 30 2 1 40 2 0 50 etc. 'ID' is a picture ID 'ev' is eyefixation (yes, no) 'time' is a consecutive run time (in ms). What I need to extract are two tings: First I need a number that depicts first, second third _consecutive_ eyefixations for each pic ID. That is some sort of counter that goes through variable 'ev' and creates a new variable that gives a '1' to the first set of consecutive cases in which ev = 1, a '2' to the second set, and so on. So, for this example, the counter would be '0' for the first 2 cases of ID 1, '1' for cases 3-5, '0' for cases 6-8, and '2' for cases 9-10 and so on. If that were possible, I would then like to calculate the fixation times for each distinct block consecutive fixations. So, how long did people look at the picture when they first looked, and thereafter. For Id 1, the first block of time would be 30 ms (cases 2-5), the second block of time would be 20 ms (cases 9-10); for ID it would be 30 ms (cases 3-5). Does someone have any idea on how/if this is possible..??? Thanks in advance for any help! ~Esther ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
In reply to this post by Esther Fujiwara
Since your description is rather inconsistent I leave you to look at the LAG function in COMPUTE and AGGREGATE commands!
If you more carefully describe how you get your durations maybe more to come. How is it cases 2-5 are in the first and 9-10 in the second. Is it NECESSARY that the 1's get enumerated and the 0's get set to 0? If so it will be a pain in the ass, if not then utterly trivial! IF ID NE LAG(ID) OR $CASENUM=1 CountX = 1. IF ev EQ LAG(EV) CountX = LAG(CountX). IF MISSING(CountX) CountX = LAG(Countx) + 1. ---
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Esther Fujiwara
On Mon, 27 Jan 2014 15:30:30 +0000, Maguin, Eugene <[hidden email]>
wrote: >I think this yields what you want. Does it? Gene Maguin > >data list list / ID ev time. >begin data >1 0 0 >1 0 10 >1 1 20 >1 1 30 >1 1 40 >1 0 50 >1 0 60 >1 0 70 >1 1 80 >1 1 90 >2 0 0 >2 0 10 >2 1 20 >2 1 30 >2 1 40 >2 0 50 >end data. > >Compute efcount=0. >Do if (id eq lag(id)). >If (ev eq 1) efcount=lag(efcount)+1. >If (ev eq 0) efcount=lag(efcount). >End if. >execute. >Aggregate outfile=* mode=addvariables/break= id efcount/fixtime=sum(time). >format ID ev(f1.0) time efcount(f2.0) fixtime(f3.0). >list id ev time efcount fixtime. > >ID ev time efcount fixtime > > 1 0 0 0 10 > 1 0 10 0 10 > 1 1 20 1 20 > 1 1 30 2 30 > 1 1 40 3 220 > 1 0 50 3 220 > 1 0 60 3 220 > 1 0 70 3 220 > 1 1 80 4 80 > 1 1 90 5 90 > 2 0 0 0 10 > 2 0 10 0 10 > 2 1 20 1 20 > 2 1 30 2 30 > 2 1 40 3 90 > 2 0 50 3 90 > >Number of cases read: 16 Number of cases listed: 16 > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of >Sent: Saturday, January 25, 2014 2:15 PM >To: [hidden email] >Subject: Calculate time/event type across cases > >Hi, >I am running into a seemingly simple problem I cannot figure out so far. >In short, my data looks like this: > >ID ev time >1 0 0 >1 0 10 >1 1 20 >1 1 30 >1 1 40 >1 0 50 >1 0 60 >1 0 70 >1 1 80 >1 1 90 >etc. >2 0 0 >2 0 10 >2 1 20 >2 1 30 >2 1 40 >2 0 50 >etc. > >'ID' is a picture ID >'ev' is eyefixation (yes, no) >'time' is a consecutive run time (in ms). > >What I need to extract are two tings: > >First I need a number that depicts first, second third _consecutive_ variable 'ev' and creates a new variable that gives a '1' to the first set of consecutive cases in which ev = 1, a '2' to the second set, and so on. >So, for this example, the counter would be '0' for the first 2 cases of ID 1, '1' for cases 3-5, '0' for cases 6-8, and '2' for cases 9-10 and so on. > >If that were possible, I would then like to calculate the fixation times for each distinct block consecutive fixations. So, how long did people look at the picture when they first looked, and thereafter. For Id 1, the first block of time would be 30 ms (cases 2-5), the second block of time would be >20 ms (cases 9-10); for ID it would be 30 ms (cases 3-5). > >Does someone have any idea on how/if this is possible..??? > >Thanks in advance for any help! > >~Esther > >===================== >To manage your subscription to SPSSX-L, send a message to command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD > >===================== >To manage your subscription to SPSSX-L, send a message to >[hidden email] (not to SPSSX-L), with no body text except the >command. To leave the list, send the command >SIGNOFF SPSSX-L >For a list of commands to manage subscriptions, send the command >INFO REFCARD Beautiful!!! This is exactly what I needed - did not occur to me to use a counter this way. Thank you! Esther ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |