SPSS: creating dummy variable using multiple variables and consecutive cases

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

SPSS: creating dummy variable using multiple variables and consecutive cases

Tufayel Chowdhury
Hello

I'm new to the group and to SPSS syntax as well. I need to create a dummy variable using three variables: START, END and DURATION. If the END of a case is not equal to the START of the next case, then DUMMY=1 for both the cases (case 1 and 2 of the following example). If the END of a case is equal to the START of the next case (case 3 and case 4 in the example), then of the two cases the one having higher DURATION will get DUMMY=1 and the other one will get DUMMY=0. Consider the last 4 cases where the END of a case is equal to the START of the next case- DUMMY=1 for the case having the highest DURATION and the rest three cases get DUMMY=0. 

To reiterate my problem, I need to select only one event out of several consecutive events that has the highest duration.

START END DURATION DUMMY
264     271   7     1
273     278   5     1
582  !    583   1     0
583     596   13     1
613     616   3     1
512     518   6     1
185     197   12     0
197     227   30     1
227     237   10     0
237     242   5     0

Could anyone please suggest how to create that DUMMY in SPSS?

Thanks in advance!
Tufayel

Reply | Threaded
Open this post in threaded view
|

Re: SPSS: creating dummy variable using multiple variables and consecutive cases

Bruce Weaver
Administrator
The same question was posted in the SPSS newsgroup (http://groups.google.com/group/comp.soft-sys.stat.spss/topics).  My response there was:

"You need to compare values across cases.   I think you might find the
SHIFT VALUES command useful.  You can find examples in the Help files."



Tufayel Chowdhury wrote
Hello

I'm new to the group and to SPSS syntax as well. I need to create a dummy
variable using three variables: START, END and DURATION. If the END of a case is
not equal to the START of the next case, then DUMMY=1 for both the cases (case 1
and 2 of the following example). If the END of a case is equal to the START of
the next case (case 3 and case 4 in the example), then of the two cases the one
having higher DURATION will get DUMMY=1 and the other one will get DUMMY=0.
Consider the last 4 cases where the END of a case is equal to the START of the
next case- DUMMY=1 for the case having the highest DURATION and the rest three
cases get DUMMY=0.

To reiterate my problem, I need to select only one event out of several
consecutive events that has the highest duration.

START END DURATION DUMMY
264    271  7    1
273    278  5    1
582    583  1    0
583    596  13    1
613    616  3    1
512    518  6    1
185    197  12    0
197    227  30    1
227    237  10    0
237    242  5    0

Could anyone please suggest how to create that DUMMY in SPSS?

Thanks in advance!
Tufayel

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).