Date: Tue, 11 Jan 2005 12:25:20 -0500
Reply-To: Richard Ristow <wrristow@mindspring.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <wrristow@mindspring.com>
Subject: Re: Check months of current year v months of previous year
In-Reply-To: <5BA49D8F15EDD41181F3006094B230F80175BB57@MAILNN>
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 04:16 AM 1/11/2005, Paparodopoulos, Nikos wrote:
>I have a file that shows for each person the duration of his
>employment
>under a certain project.
>
>For example:
>
>Employee Effective_Project_Date Lapse_Project_Date
>
> 1 2-12-1997 4-5-2006
> 2 14-5-2000 3-6-2004
> 3 1-1-1999 9-9-2004
> 4 29-3-1994 17-4-2005
> 5 1-1-1997 1-12-2003
>
>I would like to add 12 Flag Variables (for each month of 2004) that
>will show:
>1 if the employee was working on the same month of previous year & he
>is still working on the same month of the current year (e.g. for March
>2004 for employee= 2, Flag_March2004/2003 = 1);
>0 if the employee was working on the same month of previous year but
>he
>is not working on the same month of the current year (e.g. for October
>2004
>for employee= 3, Flag_October2004/2003 = 0)
There's a question: what if the employee was NOT working on that month
in 2003? There don't seem to be any of those in your data, but I'll
code them as 9. This is SPSS draft output:
List
EMP EFFCT_DT LAPSE_DT
1 02-DEC-1997 04-MAY-2006
2 14-MAY-2000 03-JUN-2004
3 01-JAN-1999 09-SEP-2004
4 29-MAR-1994 17-APR-2005
5 01-JAN-1997 01-DEC-2003
Number of cases read: 5 Number of cases listed: 5
NUMERIC
F_JAN F_FEB F_MAR F_APR F_MAY F_JUN
F_JUL F_AUG F_SEP F_OCT F_NOV F_DEC (F2).
VECTOR FLAGS = F_JAN TO F_DEC.
LOOP #MONTH = 1 TO 12.
* Working in selected month in 2003? .
- DO IF EFFCT_DT >= DATE.DMY(1,#MONTH+1,2003).
* Not if started after the month ended.
. COMPUTE #WK_2003 = 0.
- ELSE IF LAPSE_DT < DATE.DMY(1,#MONTH ,2003).
* Not if ended before the month began.
. COMPUTE #WK_2003 = 0.
- ELSE.
* Otherwise, yes .
. COMPUTE #WK_2003 = 1.
- END IF.
* Working in selected month in 2004? .
- DO IF EFFCT_DT >= DATE.DMY(1,#MONTH+1,2004).
* Not if started after the month ended.
. COMPUTE #WK_2004 = 0.
- ELSE IF LAPSE_DT < DATE.DMY(1,#MONTH ,2004).
* Not if ended before the month began.
. COMPUTE #WK_2004 = 0.
- ELSE.
* Otherwise, yes .
. COMPUTE #WK_2004 = 1.
- END IF.
* Setting for the flag variable .
- DO IF #WK_2003 = 0.
. COMPUTE FLAGS(#MONTH) = 9.
- ELSE IF #WK_2004 = 0.
. COMPUTE FLAGS(#MONTH) = 0.
- ELSE.
. COMPUTE FLAGS(#MONTH) = 1.
- END IF.
END LOOP.
STRING SPACER(A16).
LIST.
List
F F F F F F F F F F F F
_ _ _ _ _ _ _ _ _ _ _ _
E J F M A M J J A S O N D
M A E A P A U U U E C O E
P EFFCT_DT LAPSE_DT N B R R Y N L G P T V C
1 02-DEC-1997 04-MAY-2006 1 1 1 1 1 1 1 1 1 1 1 1
2 14-MAY-2000 03-JUN-2004 1 1 1 1 1 1 0 0 0 0 0 0
3 01-JAN-1999 09-SEP-2004 1 1 1 1 1 1 1 1 1 0 0 0
4 29-MAR-1994 17-APR-2005 1 1 1 1 1 1 1 1 1 1 1 1
5 01-JAN-1997 01-DEC-2003 0 0 0 0 0 0 0 0 0 0 0 0
Number of cases read: 5 Number of cases listed: 5