calculating duration of status

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

calculating duration of status

J Scelza
I have a data set which contains the following:


1) at least two records per client;

2) one time variable called "date of employment"; and

3) three variables indicating employment status of a client:
       "employment status" (1=employed, 3=unemployed), "employment change
       1" (2=changed from employed to unemployed, -2=changed from
       unemployed to employed, 0=no change from the previous record for
       this client), and "employment change 2" (1=employed to unemployed,
       2=unemployed to employed, 3=oscillating employment, and 4=no
       overall subsequent change in employment).


I would like to know how to write the SYNTAX, if possible, to determine
the length of time that a client was employed or unemployed before his or
her status changed.

The data set looks something like this:

CaseID        Date of Emp Status    EmpStatus  EmpChange1  EmpChange2
1                 01-APR-2006          1           .           4
1                 01-MAY-2006          1           0           4
3                 01-AUG-2005          3           .           3
3                 01-SEP-2005          1          -2           3
3                 01-OCT-2005          3           2           3
4                 01-AUG-2005          3           .           2
4                 01-SEP-2005          1          -2           2
5                 01-FEB-2006          1           .           1
5                 01-MAR-2006          3           2           1
6                 01-MAR-2006          1           .           3
6                 01-APR-2006          3           2           3
6                 01-MAY-2006          1          -2           3
7                 01-JAN-2006          1           .           4
7                 01-FEB-2006          1           0           4
7                 01-MAR-2006          1           0           4
7                 01-APR-2006          1           0           4
7                 01-MAY-2006          1           0           4


The syntax file I have so far also includes using the lag function to
determine the difference in the date of employment status. Or, at the very
least, where a client has a continuous employment status (like CaseID 7 in
the example above), I would like to determine how long (in days) he or she
was employed.



Janene
Reply | Threaded
Open this post in threaded view
|

Re: calculating duration of status

Richard Ristow
(This is a follow-up to thread "syntax for creating a pattern
variable", Fri, 16 Mar 2007 <12:17:02 -0400> ff.)

At 01:45 PM 4/10/2007, J Scelza wrote:

>I have a data set which contains the following:
>1) at least two records per client;
>2) one time variable called "date of employment"; and
>3) three variables indicating employment status of a client:
>        "employment status"   (1=employed, 3=unemployed),
>        "employment change 1" (2=changed from employed to unemployed,
>                              -2=changed from unemployed to employed,
>                               0=no change from the previous record
>                                 for this client),
>    and "employment change 2" (1=employed to unemployed,
>                               2=unemployed to employed,
>                               3=oscillating employment, and
>                               4=no overall subsequent change
>                               in employment).
>
>
>I would like to determine the length of time that a client was
>employed or unemployed before his or her status changed. At the very
>least, where a client has a continuous employment status (like CaseID
>7 in the example above), I would like to determine how long (in days)
>he or she was employed.

It's not clear what you want: whether one number for each continuous
period in the same status, one number per client, or what? And as you
have it, you can't get duration in days. Your date resolution is to
month, only; you don't have the dates of status change.

Anyway, try the below as a beginning. I'm taking the problem, and the
logic, as very similar to thread "Counting Consecutive Dates or Gaps in
dates" (dates, Wed, 4 Apr 2007 <10:17:44 -0400> ff; my solution, Wed, 4
Apr 2007 <14:10:00 -0400>). SPSS 15 draft output:

|-----------------------------|---------------------------|
|Output Created               |11-APR-2007 16:33:34       |
|-----------------------------|---------------------------|
CaseID    StatusDT EmpStatus EmpChange1 EmpChange2

    1   01-APR-2006      1         .          4
    1   01-MAY-2006      1         0          4
    3   01-AUG-2005      3         .          3
    3   01-SEP-2005      1        -2          3
    3   01-OCT-2005      3         2          3
    4   01-AUG-2005      3         .          2
    4   01-SEP-2005      1        -2          2
    5   01-FEB-2006      1         .          1
    5   01-MAR-2006      3         2          1
    6   01-MAR-2006      1         .          3
    6   01-APR-2006      3         2          3
    6   01-MAY-2006      1        -2          3
    7   01-JAN-2006      1         .          4
    7   01-FEB-2006      1         0          4
    7   01-MAR-2006      1         0          4
    7   01-APR-2006      1         0          4
    7   01-MAY-2006      1         0          4

Number of cases read:  17    Number of cases listed:  17


*  "I would like to determine the length of time that a client .
*  was employed or unemployed before his or her status changed".

*  Step I:   Length of time, through current month             .
*  (Logic assumes that CaseID and EmpStatus are never missing) .

NUMERIC    TimeInStat (F3).
VAR LABEL  TimeInStat
           'Number of months in current employment status'.
DO IF        MISSING(LAG(CaseID)).
.  COMPUTE TimeInStat = 1.
ELSE IF CaseID    NE LAG(CaseID).
.  COMPUTE TimeInStat = 1.
ELSE IF EmpStatus NE LAG(EmpStatus).
.  COMPUTE TimeInStat = 1.
ELSE.
.  COMPUTE TimeInStat = 1 + LAG(TimeInStat).
END IF.
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |11-APR-2007 16:33:35       |
|-----------------------------|---------------------------|
CaseID    StatusDT EmpStatus EmpChange1 EmpChange2 TimeInStat

    1   01-APR-2006      1         .          4           1
    1   01-MAY-2006      1         0          4           2
    3   01-AUG-2005      3         .          3           1
    3   01-SEP-2005      1        -2          3           1
    3   01-OCT-2005      3         2          3           1
    4   01-AUG-2005      3         .          2           1
    4   01-SEP-2005      1        -2          2           1
    5   01-FEB-2006      1         .          1           1
    5   01-MAR-2006      3         2          1           1
    6   01-MAR-2006      1         .          3           1
    6   01-APR-2006      3         2          3           1
    6   01-MAY-2006      1        -2          3           1
    7   01-JAN-2006      1         .          4           1
    7   01-FEB-2006      1         0          4           2
    7   01-MAR-2006      1         0          4           3
    7   01-APR-2006      1         0          4           4
    7   01-MAY-2006      1         0          4           5

Number of cases read:  17    Number of cases listed:  17


*  Step II:  Length of interval of one employment status       .

NUMERIC   StatStrtDT (DATE11).
VAR LABEL StatStrtDT 'Date when current status began'.
DO IF   TimeInStat EQ 1.
.  COMPUTE StatStrtDT = StatusDT.
ELSE.
.  COMPUTE StatStrtDT = LAG(StatStrtDT).
END IF.

AGGREGATE OUTFILE=*
    /BREAK     = CaseID StatStrtDT
    /EmpStatus = FIRST(EmpStatus)
    /StatusLN 'Duration in status, months'
               = MAX(TimeInStat).

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |11-APR-2007 16:33:36       |
|-----------------------------|---------------------------|
CaseID  StatStrtDT EmpStatus StatusLN

    1   01-APR-2006      1         2
    3   01-AUG-2005      3         1
    3   01-SEP-2005      1         1
    3   01-OCT-2005      3         1
    4   01-AUG-2005      3         1
    4   01-SEP-2005      1         1
    5   01-FEB-2006      1         1
    5   01-MAR-2006      3         1
    6   01-MAR-2006      1         1
    6   01-APR-2006      3         1
    6   01-MAY-2006      1         1
    7   01-JAN-2006      1         5

Number of cases read:  12    Number of cases listed:  12
===================
APPENDIX: Test data
===================
* ............   Test data               ............          .
* (from the original posting)                                  .

DATA LIST LIST SKIP=1/
   CaseID  StatusDT            EmpStatus  EmpChange1  EmpChange2
   (F2,    DATE,               3F2).
BEGIN DATA
   CaseID  Date of Emp Status  EmpStatus  EmpChange1  EmpChange2
   1           01-APR-2006        1           .           4
   1           01-MAY-2006        1           0           4
   3           01-AUG-2005        3           .           3
   3           01-SEP-2005        1          -2           3
   3           01-OCT-2005        3           2           3
   4           01-AUG-2005        3           .           2
   4           01-SEP-2005        1          -2           2
   5           01-FEB-2006        1           .           1
   5           01-MAR-2006        3           2           1
   6           01-MAR-2006        1           .           3
   6           01-APR-2006        3           2           3
   6           01-MAY-2006        1          -2           3
   7           01-JAN-2006        1           .           4
   7           01-FEB-2006        1           0           4
   7           01-MAR-2006        1           0           4
   7           01-APR-2006        1           0           4
   7           01-MAY-2006        1           0           4
END DATA.
SORT CASES BY CaseID  StatusDT.
Reply | Threaded
Open this post in threaded view
|

Re: calculating duration of status

Dennis Deck
In reply to this post by J Scelza
Calc time between observations for each case like:

IF ($casenum>1 and ID=LAG(ID)) Days = CTIME.days(ESDate - LAG(ESDate)) .

Then compute running sum conditional on status and status change.

Dennis Deck, PhD
RMC Research Corporation
[hidden email]

-----Original Message-----
From: J Scelza [mailto:[hidden email]]
Sent: Tuesday, April 10, 2007 10:46 AM
Subject: calculating duration of status

I have a data set which contains the following:


1) at least two records per client;

2) one time variable called "date of employment"; and

3) three variables indicating employment status of a client:
       "employment status" (1=employed, 3=unemployed), "employment
change
       1" (2=changed from employed to unemployed, -2=changed from
       unemployed to employed, 0=no change from the previous record for
       this client), and "employment change 2" (1=employed to
unemployed,
       2=unemployed to employed, 3=oscillating employment, and 4=no
       overall subsequent change in employment).


I would like to know how to write the SYNTAX, if possible, to determine
the length of time that a client was employed or unemployed before his
or
her status changed.

The data set looks something like this:

CaseID        Date of Emp Status    EmpStatus  EmpChange1  EmpChange2
1                 01-APR-2006          1           .           4
1                 01-MAY-2006          1           0           4
3                 01-AUG-2005          3           .           3
3                 01-SEP-2005          1          -2           3
3                 01-OCT-2005          3           2           3
4                 01-AUG-2005          3           .           2
4                 01-SEP-2005          1          -2           2
5                 01-FEB-2006          1           .           1
5                 01-MAR-2006          3           2           1
6                 01-MAR-2006          1           .           3
6                 01-APR-2006          3           2           3
6                 01-MAY-2006          1          -2           3
7                 01-JAN-2006          1           .           4
7                 01-FEB-2006          1           0           4
7                 01-MAR-2006          1           0           4
7                 01-APR-2006          1           0           4
7                 01-MAY-2006          1           0           4


The syntax file I have so far also includes using the lag function to
determine the difference in the date of employment status. Or, at the
very
least, where a client has a continuous employment status (like CaseID 7
in
the example above), I would like to determine how long (in days) he or
she
was employed.



Janene
Reply | Threaded
Open this post in threaded view
|

Spss on mac questions

Maguin, Eugene
In reply to this post by J Scelza
All,

Just today I was helping a student with an analysis done on a mac with v13
or v12. I was going to change his spss setup parameters. These are the ones
accessible through edit-->options on a pc version. I couldn't find an
options line on the edit menu. Does anybody know how to get to that set of
menus on the mac version?

Second question (and this applies to both the pc and mac versions) From the
menu system, the reliability procedure
(analysis-->scale/scaling-->reliability) does not obviously show how to get
the item-total correlations that are obtainable on the /summary=total
subcommand-keyword in syntax. I can't believe it's been left off but the
'total' keyword does not appear on either mac 12/13 menu or the pc 14 menu.

Thanks, Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: Spss on mac questions

Reutter, Alex
Re: second question

The "Scale if item deleted" under the "Descriptives for" group pastes the /summary=total syntax.

Alex

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Thursday, April 12, 2007 12:39 PM
To: [hidden email]
Subject: Spss on mac questions

All,

Just today I was helping a student with an analysis done on a mac with v13
or v12. I was going to change his spss setup parameters. These are the ones
accessible through edit-->options on a pc version. I couldn't find an
options line on the edit menu. Does anybody know how to get to that set of
menus on the mac version?

Second question (and this applies to both the pc and mac versions) From the
menu system, the reliability procedure
(analysis-->scale/scaling-->reliability) does not obviously show how to get
the item-total correlations that are obtainable on the /summary=total
subcommand-keyword in syntax. I can't believe it's been left off but the
'total' keyword does not appear on either mac 12/13 menu or the pc 14 menu.

Thanks, Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: Spss on mac questions

Oliver, Richard
Re: first question:

Instead of Edit > Options, the Mac standard is [Application menu] > Preferences. In the case of SPSS 13 for example, that would be:
SPSS 13 > Preferences

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Reutter, Alex
Sent: Thursday, April 12, 2007 4:26 PM
To: [hidden email]
Subject: Re: Spss on mac questions

Re: second question

The "Scale if item deleted" under the "Descriptives for" group pastes the /summary=total syntax.

Alex

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Thursday, April 12, 2007 12:39 PM
To: [hidden email]
Subject: Spss on mac questions

All,

Just today I was helping a student with an analysis done on a mac with v13
or v12. I was going to change his spss setup parameters. These are the ones
accessible through edit-->options on a pc version. I couldn't find an
options line on the edit menu. Does anybody know how to get to that set of
menus on the mac version?

Second question (and this applies to both the pc and mac versions) From the
menu system, the reliability procedure
(analysis-->scale/scaling-->reliability) does not obviously show how to get
the item-total correlations that are obtainable on the /summary=total
subcommand-keyword in syntax. I can't believe it's been left off but the
'total' keyword does not appear on either mac 12/13 menu or the pc 14 menu.

Thanks, Gene Maguin