Missing dates?

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

Ctable question - 2 vars with different statistics in ONE tab

Thien Hop
Hi all,
 
I have a question regarding Ctable in SPSS 18. When I try to run a tab that combines 2 variables with different statistics ie. Col % & Mean+std, it shows an extra column to display "mean/ std", this is quite anoying as I can hardly align it with all other tabs that involve only ONE variable. This does not happen in SPSS 12. In version 18, if I change the VISIBLE=NO, then the extra column is removed but the lable "Mean & Std" also disappear.
 
Could anyone please advise how to collapse the extra column (in tab Attribute 1) but the label still shown.
 
S1a. Gender 
  Grand
Total
  S1a. Record Gender  Total 844
Male 28
Female 72
Base: All Respondents
Attribute 1
  Grand
Total
  $q8a_1 Total   628
Not fit at all    7
2   26
3   35
4   28
Fit very well   4
4+5
 
32
1+2
 
33
    Mean 2.95
  Std .99
Base: All Respondents
 
Thank you so much,
 
Hop
 
Reply | Threaded
Open this post in threaded view
|

Re: Ctable question - 2 vars with different statistics in ONE tab

Luca Meyer-3
temp.htm
Hello Hop,

I am not sure I have correctly understood what you are looking for. 

If you are trying to transform a table like:

  Column N % Count Mean Standard Deviation
AGE 5 25,0%      
6 12,5%      
10 37,5%      
15 12,5%      
18 12,5%      
Total   8 10 5

Into something like:

AGE 5 Column N % 25,0%
6 Column N % 12,5%
10 Column N % 37,5%
15 Column N % 12,5%
18 Column N % 12,5%
Total Count 8
Mean 10
Standard Deviation 5

Then you should add a   
/SLABELS POSITION=ROW
command to your CTABLES syntax.

Below I post the syntax I used to generate both tables:

DATASET CLOSE ALL.
NEW FILE.
DATA LIST LIST /V1.
BEGIN DATA
10
10
5
6
18
15
5
10
END DATA.
EXE.

VAR LABEL V1 "AGE".
FORMAT V1 (F2.0).

CTABLES
  /VLABELS VARIABLES=V1 DISPLAY=LABEL
  /TABLE V1 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0, MEAN, STDDEV]]
  /CATEGORIES VARIABLES=V1 ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL='Total' POSITION=AFTER 
    MISSING=EXCLUDE.

CTABLES
  /VLABELS VARIABLES=V1 DISPLAY=LABEL
  /TABLE V1 [C][COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0, MEAN, STDDEV]]
  /SLABELS POSITION=ROW
  /CATEGORIES VARIABLES=V1 ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL='Total' POSITION=AFTER 
    MISSING=EXCLUDE.

If you need something else please post again with more details and possibly some sample syntax you are using.

Cheers,
Luca

Luca Meyer
www.lucameyer.com
PASW Statistics v. 18.0.2 (2-apr-2010)
R version 2.9.2 (2009-08-24)
Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0


Il giorno 28/apr/2010, alle ore 15.12, Thien Hop ha scritto:

Hi all,
 
I have a question regarding Ctable in SPSS 18. When I try to run a tab that combines 2 variables with different statistics ie. Col % & Mean+std, it shows an extra column to display "mean/ std", this is quite anoying as I can hardly align it with all other tabs that involve only ONE variable. This does not happen in SPSS 12. In version 18, if I change the VISIBLE=NO, then the extra column is removed but the lable "Mean & Std" also disappear.
 
Could anyone please advise how to collapse the extra column (in tab Attribute 1) but the label still shown.
 
S1a. Gender 
 Grand
Total
 S1a. Record Gender Total844
Male28
Female72
Base: All Respondents
Attribute 1
 Grand
Total
 $q8a_1Total 628
Not fit at all  7
2 26
3 35
4 28
Fit very well 4
4+5
 
32
1+2
 
33
  Mean2.95
 Std.99
Base: All Respondents
 
Thank you so much,
 
Hop
 









Reply | Threaded
Open this post in threaded view
|

Re: Ctable question - 2 vars with different statistics in ONE tab

Luca Meyer-3
Hi Hop,

I am rushing thru jobs right now but have you tried the following?

  /SLABELS POSITION=ROW VISIBLE=NO

Luca

Il giorno 29/apr/2010, alle ore 05.36, Thien Hop ha scritto:

Hi Luca,
 
Thank you very much for your advice, actually I want the label "count + Mean + Standard Deviation" to be on the same column with the codes of age. Normally, I don't want to show the column after the codes ie. "Col %".
 

AGE

Total

Count

8

5

col %

25.0%

6

col %

12.5%

10

col %

37.5%

15

col %

12.5%

18

col %

12.5%


Mean

9.88

Standard Deviation

4.70

 
I found the way to do it as follows:
 
compute sv1=v1.
var lab sv1 ''.
exe
 
CTABLES
  /VLABELS VARIABLES=V1 sv1 DISPLAY=LABEL
  /TABLE V1 [C][COLPCT.COUNT 'Col %' PCT40.1, TOTALS[COUNT F40.0]] + sv1[MEAN F40.2, STDDEV F40.2]]
  /SLABELS POSITION=ROW VISIBLE=YES
  /CATEGORIES VARIABLES=V1 ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL='Total' POSITION=BEFORE 
    MISSING=EXCLUDE.
 
What I just need to do is deleting column containing "Col %" when exporting it to Excel. The difference of SPSS 18 vs SPSS 12 as I realize is that the earlier won't show extra column if we don't include somthing for SLABELS ie. "col %" while the later (v12) will always show an extra column after the stub codes.
 
Thanks a lot,
 
Hop
 
----- Original Message -----
Sent: Wednesday, April 28, 2010 11:23 PM
Subject: Re: Ctable question - 2 vars with different statistics in ONE tab

Hello Hop,

I am not sure I have correctly understood what you are looking for. 

If you are trying to transform a table like:

 Column N %CountMeanStandard Deviation
AGE525,0%   
612,5%   
1037,5%   
1512,5%   
1812,5%   
Total 8105

Into something like:

AGE5Column N %25,0%
6Column N %12,5%
10Column N %37,5%
15Column N %12,5%
18Column N %12,5%
TotalCount8
Mean10
Standard Deviation5

Then you should add a   
/SLABELS POSITION=ROW
command to your CTABLES syntax.

Below I post the syntax I used to generate both tables:

DATASET CLOSE ALL.
NEW FILE.
DATA LIST LIST /V1.
BEGIN DATA
10
10
5
6
18
15
5
10
END DATA.
EXE.

VAR LABEL V1 "AGE".
FORMAT V1 (F2.0).

CTABLES
  /VLABELS VARIABLES=V1 DISPLAY=LABEL
  /TABLE V1 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0, MEAN, STDDEV]]
  /CATEGORIES VARIABLES=V1 ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL='Total' POSITION=AFTER 
    MISSING=EXCLUDE.

CTABLES
  /VLABELS VARIABLES=V1 DISPLAY=LABEL
  /TABLE V1 [C][COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0, MEAN, STDDEV]]
  /SLABELS POSITION=ROW
  /CATEGORIES VARIABLES=V1 ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL='Total' POSITION=AFTER 
    MISSING=EXCLUDE.

If you need something else please post again with more details and possibly some sample syntax you are using.

Cheers,
Luca

Luca Meyer
www.lucameyer.com
PASW Statistics v. 18.0.2 (2-apr-2010)
R version 2.9.2 (2009-08-24)
Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0


Il giorno 28/apr/2010, alle ore 15.12, Thien Hop ha scritto:

Hi all,
 
I have a question regarding Ctable in SPSS 18. When I try to run a tab that combines 2 variables with different statistics ie. Col % & Mean+std, it shows an extra column to display "mean/ std", this is quite anoying as I can hardly align it with all other tabs that involve only ONE variable. This does not happen in SPSS 12. In version 18, if I change the VISIBLE=NO, then the extra column is removed but the lable "Mean & Std" also disappear.
 
Could anyone please advise how to collapse the extra column (in tab Attribute 1) but the label still shown.
 
S1a. Gender 
 Grand
Total
 S1a. Record Gender Total844
Male28
Female72
Base: All Respondents
Attribute 1
 Grand
Total
 $q8a_1Total 628
Not fit at all  7
2 26
3 35
4 28
Fit very well 4
4+5
 
32
1+2
 
33
  Mean2.95
 Std.99
Base: All Respondents
 
Thank you so much,
 
Hop
 











Reply | Threaded
Open this post in threaded view
|

Re: Ctable question - 2 vars with different statistics in ONE tab

Thien Hop
Hi Luca,
 
I tried it (VISIBLE=NO) & the "Mean & Standard Deviation" is gone. Anyway, it works when I copy the variable to temp var for "mean+std" & add Slabel for the primary variable "col %". I just need to delete the extra column & the label "mean+std" is still there.
 
Thanks,
 
Hop
----- Original Message -----
Sent: Thursday, April 29, 2010 3:41 PM
Subject: Re: Ctable question - 2 vars with different statistics in ONE tab

Hi Hop,

I am rushing thru jobs right now but have you tried the following?

  /SLABELS POSITION=ROW VISIBLE=NO

Luca

Il giorno 29/apr/2010, alle ore 05.36, Thien Hop ha scritto:

Hi Luca,
 
Thank you very much for your advice, actually I want the label "count + Mean + Standard Deviation" to be on the same column with the codes of age. Normally, I don't want to show the column after the codes ie. "Col %".
 

AGE

Total

Count

8

5

col %

25.0%

6

col %

12.5%

10

col %

37.5%

15

col %

12.5%

18

col %

12.5%


Mean

9.88

Standard Deviation

4.70

 
I found the way to do it as follows:
 
compute sv1=v1.
var lab sv1 ''.
exe
 
CTABLES
  /VLABELS VARIABLES=V1 sv1 DISPLAY=LABEL
  /TABLE V1 [C][COLPCT.COUNT 'Col %' PCT40.1, TOTALS[COUNT F40.0]] + sv1[MEAN F40.2, STDDEV F40.2]]
  /SLABELS POSITION=ROW VISIBLE=YES
  /CATEGORIES VARIABLES=V1 ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL='Total' POSITION=BEFORE 
    MISSING=EXCLUDE.
 
What I just need to do is deleting column containing "Col %" when exporting it to Excel. The difference of SPSS 18 vs SPSS 12 as I realize is that the earlier won't show extra column if we don't include somthing for SLABELS ie. "col %" while the later (v12) will always show an extra column after the stub codes.
 
Thanks a lot,
 
Hop
 
----- Original Message -----
Sent: Wednesday, April 28, 2010 11:23 PM
Subject: Re: Ctable question - 2 vars with different statistics in ONE tab

Hello Hop,

I am not sure I have correctly understood what you are looking for. 

If you are trying to transform a table like:

  Column N % Count Mean Standard Deviation
AGE 5 25,0%      
6 12,5%      
10 37,5%      
15 12,5%      
18 12,5%      
Total   8 10 5

Into something like:

AGE 5 Column N % 25,0%
6 Column N % 12,5%
10 Column N % 37,5%
15 Column N % 12,5%
18 Column N % 12,5%
Total Count 8
Mean 10
Standard Deviation 5

Then you should add a   
/SLABELS POSITION=ROW
command to your CTABLES syntax.

Below I post the syntax I used to generate both tables:

DATASET CLOSE ALL.
NEW FILE.
DATA LIST LIST /V1.
BEGIN DATA
10
10
5
6
18
15
5
10
END DATA.
EXE.

VAR LABEL V1 "AGE".
FORMAT V1 (F2.0).

CTABLES
  /VLABELS VARIABLES=V1 DISPLAY=LABEL
  /TABLE V1 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0, MEAN, STDDEV]]
  /CATEGORIES VARIABLES=V1 ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL='Total' POSITION=AFTER 
    MISSING=EXCLUDE.

CTABLES
  /VLABELS VARIABLES=V1 DISPLAY=LABEL
  /TABLE V1 [C][COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0, MEAN, STDDEV]]
  /SLABELS POSITION=ROW
  /CATEGORIES VARIABLES=V1 ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL='Total' POSITION=AFTER 
    MISSING=EXCLUDE.

If you need something else please post again with more details and possibly some sample syntax you are using.

Cheers,
Luca

Luca Meyer
www.lucameyer.com
PASW Statistics v. 18.0.2 (2-apr-2010)
R version 2.9.2 (2009-08-24)
Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0


Il giorno 28/apr/2010, alle ore 15.12, Thien Hop ha scritto:

Hi all,
 
I have a question regarding Ctable in SPSS 18. When I try to run a tab that combines 2 variables with different statistics ie. Col % & Mean+std, it shows an extra column to display "mean/ std", this is quite anoying as I can hardly align it with all other tabs that involve only ONE variable. This does not happen in SPSS 12. In version 18, if I change the VISIBLE=NO, then the extra column is removed but the lable "Mean & Std" also disappear.
 
Could anyone please advise how to collapse the extra column (in tab Attribute 1) but the label still shown.
 
S1a. Gender 
  Grand
Total
  S1a. Record Gender  Total 844
Male 28
Female 72
Base: All Respondents
Attribute 1
  Grand
Total
  $q8a_1 Total   628
Not fit at all    7
2   26
3   35
4   28
Fit very well   4
4+5
 
32
1+2
 
33
    Mean 2.95
  Std .99
Base: All Respondents
 
Thank you so much,
 
Hop
 











Reply | Threaded
Open this post in threaded view
|

Overlapping Periods

Asil Ozdogru
In reply to this post by Albert-Jan Roskam

Hello,

 

I would like to get the earliest in and latest out dates among a set of overlapping periods using syntax.

An example is provided below.

 

Could anyone help me with that?

 

Thanks,

 

Asil

 

EXAMPLE:

I would like to go from this set

StudyID

InDate

OutDate

30006

9/20/2002

4/30/2007

30006

12/29/2006

5/31/2012

30006

11/25/2009

5/31/2012

30014

4/16/1975

3/3/1988

30014

4/21/1980

5/28/1982

30014

2/16/2001

11/24/2001

30022

2/5/1992

7/22/1995

30057

2/1/1988

11/20/1988

30057

12/15/1989

10/17/1990

30057

1/23/1992

10/18/1993

 

To this set

StudyID

InDate

OutDate

30006

9/20/2002

5/31/2012

30014

4/16/1975

3/3/1988

30014

2/16/2001

11/24/2001

30022

2/5/1992

7/22/1995

30057

2/1/1988

11/20/1988

30057

12/15/1989

10/17/1990

30057

1/23/1992

10/18/1993

 

Reply | Threaded
Open this post in threaded view
|

Re: Overlapping Periods

Maguin, Eugene
Asil,

I might be misunderstanding, but this looks like a straight forward
application of Aggregate where you select the min value of Indate and the
max value of OutDate.

Gene Maguin


>>I would like to get the earliest in and latest out dates among a set of
overlapping periods using syntax.
An example is provided below.
Could anyone help me with that?

Thanks,
Asil



EXAMPLE:
I would like to go from this set

StudyID InDate  OutDate
30006           9/20/2002       4/30/2007
30006           12/29/2006      5/31/2012
30006           11/25/2009      5/31/2012
30014           4/16/1975       3/3/1988
30014           4/21/1980       5/28/1982
30014           2/16/2001       11/24/2001
30022           2/5/1992        7/22/1995
30057           2/1/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           1/23/1992       10/18/1993

To this set
StudyID InDate  OutDate
30006           9/20/2002       5/31/2012
30014           4/16/1975       3/3/1988
30014           2/16/2001       11/24/2001
30022           2/5/1992        7/22/1995
30057           2/1/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           1/23/1992       10/18/1993



=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Overlapping Periods

Bruce Weaver
Administrator
In reply to this post by Asil Ozdogru
Asil Ozdogru wrote
Hello,

I would like to get the earliest in and latest out dates among a set of overlapping periods using syntax.
An example is provided below.

Could anyone help me with that?

Thanks,

Asil

EXAMPLE:

--- snip tables, because formatting was lost ---

Dates are numeric variables, so you can use the MIN and MAX functions of AGGREGATE to pull out the earliest INDATE and latest OUTDATE.  If you want the same variable names as in the original data, you'll have to set the OVERWRITE option to yes.

--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: Overlapping Periods

Marks, Jim
In reply to this post by Maguin, Eugene
Gene:

The problem set includes overlapping and non-overlapping intervals--
case 3006 goes from three to one record, while case 30057 has three
non-overlapping intervals.

Asil:

Here is a solution.

** Sample data.
NEW FILE.
DATA LIST FREE/StudyID (f8.0) InDate (ADATE10) OutDate (ADATE10).
BEGIN DATA
30006           09/20/2002       04/30/2007
30006           12/29/2006      05/31/2012
30006           11/25/2009      05/31/2012
30014           04/16/1975       03/03/1988
30014           04/21/1980       05/28/1982
30014           02/16/2001       11/24/2001
30022           02/05/1992        07/22/1995
30057           02/01/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           01/23/1992       10/18/1993
END DATA.
DATASET NAME intervals WINDOW = FRONT.

** optional if live data is presorted.
SORT CASES BY studyID indate (A).

** Identify overlapping periods.
COMPUTE sequence  = 1.
IF studyid = LAG(studyid) AND indate LE LAG(outdate) sequence =
LAG(sequence) + 1.


** create a variable to identify the start of a new overlapping period.
COMPUTE seq_start = sequence = 1.

** create a variable to number each new set of overlapping periods--
** needed to aggregate data.
FILTER BY seq_start.
RANK indate BY studyID / RANK INTO intervals.
FILTER  OFF.

** transfer the number for each new overlapping period
** down to each case in the overlapping period.
NUMERIC   #seq  (F8.0).
DO IF seq_start.
.  COMPUTE #seq = intervals.
ELSE .
.         COMPUTE intervals = #seq.
END IF .
EXECUTE .

DATASET DECLARE final_data.
AGGREGATE OUTFILE = final_data /BREAK = studyID intervals
  /indate = MIN(indate) /outdate = MAX(indate).
DATASET ACTIVATE final_data.
LIST.

Jim Marks
Director, Market Research
x1616


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gene Maguin
Sent: Wednesday, May 12, 2010 1:33 PM
To: [hidden email]
Subject: Re: Overlapping Periods

Asil,

I might be misunderstanding, but this looks like a straight forward
application of Aggregate where you select the min value of Indate and
the
max value of OutDate.

Gene Maguin


>>I would like to get the earliest in and latest out dates among a set
of
overlapping periods using syntax.
An example is provided below.
Could anyone help me with that?

Thanks,
Asil



EXAMPLE:
I would like to go from this set

StudyID InDate  OutDate
30006           9/20/2002       4/30/2007
30006           12/29/2006      5/31/2012
30006           11/25/2009      5/31/2012
30014           4/16/1975       3/3/1988
30014           4/21/1980       5/28/1982
30014           2/16/2001       11/24/2001
30022           2/5/1992        7/22/1995
30057           2/1/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           1/23/1992       10/18/1993

To this set
StudyID InDate  OutDate
30006           9/20/2002       5/31/2012
30014           4/16/1975       3/3/1988
30014           2/16/2001       11/24/2001
30022           2/5/1992        7/22/1995
30057           2/1/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           1/23/1992       10/18/1993



=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Overlapping Periods

Maguin, Eugene
Jim,

Thank you for pointing out my error. The code I posted doesn't yield the
sample output. After studying Asil's imput and output this morning, I
realize that I didn't understand the problem that Asil had posed.

Gene Maguin



Gene:

The problem set includes overlapping and non-overlapping intervals--
case 3006 goes from three to one record, while case 30057 has three
non-overlapping intervals.

Asil:

Here is a solution.

** Sample data.
NEW FILE.
DATA LIST FREE/StudyID (f8.0) InDate (ADATE10) OutDate (ADATE10).
BEGIN DATA
30006           09/20/2002       04/30/2007
30006           12/29/2006      05/31/2012
30006           11/25/2009      05/31/2012
30014           04/16/1975       03/03/1988
30014           04/21/1980       05/28/1982
30014           02/16/2001       11/24/2001
30022           02/05/1992        07/22/1995
30057           02/01/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           01/23/1992       10/18/1993
END DATA.
DATASET NAME intervals WINDOW = FRONT.

** optional if live data is presorted.
SORT CASES BY studyID indate (A).

** Identify overlapping periods.
COMPUTE sequence  = 1.
IF studyid = LAG(studyid) AND indate LE LAG(outdate) sequence =
LAG(sequence) + 1.


** create a variable to identify the start of a new overlapping period.
COMPUTE seq_start = sequence = 1.

** create a variable to number each new set of overlapping periods--
** needed to aggregate data.
FILTER BY seq_start.
RANK indate BY studyID / RANK INTO intervals.
FILTER  OFF.

** transfer the number for each new overlapping period
** down to each case in the overlapping period.
NUMERIC   #seq  (F8.0).
DO IF seq_start.
.  COMPUTE #seq = intervals.
ELSE .
.         COMPUTE intervals = #seq.
END IF .
EXECUTE .

DATASET DECLARE final_data.
AGGREGATE OUTFILE = final_data /BREAK = studyID intervals
  /indate = MIN(indate) /outdate = MAX(indate).
DATASET ACTIVATE final_data.
LIST.

Jim Marks
Director, Market Research
x1616


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gene Maguin
Sent: Wednesday, May 12, 2010 1:33 PM
To: [hidden email]
Subject: Re: Overlapping Periods

Asil,

I might be misunderstanding, but this looks like a straight forward
application of Aggregate where you select the min value of Indate and
the
max value of OutDate.

Gene Maguin


>>I would like to get the earliest in and latest out dates among a set
of
overlapping periods using syntax.
An example is provided below.
Could anyone help me with that?

Thanks,
Asil



EXAMPLE:
I would like to go from this set

StudyID InDate  OutDate
30006           9/20/2002       4/30/2007
30006           12/29/2006      5/31/2012
30006           11/25/2009      5/31/2012
30014           4/16/1975       3/3/1988
30014           4/21/1980       5/28/1982
30014           2/16/2001       11/24/2001
30022           2/5/1992        7/22/1995
30057           2/1/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           1/23/1992       10/18/1993

To this set
StudyID InDate  OutDate
30006           9/20/2002       5/31/2012
30014           4/16/1975       3/3/1988
30014           2/16/2001       11/24/2001
30022           2/5/1992        7/22/1995
30057           2/1/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           1/23/1992       10/18/1993



=====================
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

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Overlapping Periods

Bruce Weaver
Administrator
Gene Maguin wrote
Jim,

Thank you for pointing out my error. The code I posted doesn't yield the
sample output. After studying Asil's imput and output this morning, I
realize that I didn't understand the problem that Asil had posed.

Gene Maguin

And since I proposed the same solution as Gene...ditto!  

--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: Overlapping Periods

bdates
Since I need similar syntax to assess multiple psychiatric
hospitalizations within multiple episodes of care, I was particularly
interested in this thread.  When I ran the syntax, my output was:

StudyID intervals     indate    outdate

   30006     1.000 09/20/2002 11/25/2009
   30014     1.000 04/16/1975 04/21/1980
   30014     2.000 02/16/2001 02/16/2001
   30022     1.000 02/05/1992 02/05/1992
   30057     1.000 02/01/1988 02/01/1988
   30057     2.000 12/15/1989 12/15/1989
   30057     3.000 01/23/1992 01/23/1992

I don't think the syntax solves the problem yet.

Brian

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: Thursday, May 13, 2010 10:22 AM
To: [hidden email]
Subject: Re: Overlapping Periods

Gene Maguin wrote:
>
> Jim,
>
> Thank you for pointing out my error. The code I posted doesn't yield
the
> sample output. After studying Asil's imput and output this morning, I
> realize that I didn't understand the problem that Asil had posed.
>
> Gene Maguin
>
>


And since I proposed the same solution as Gene...ditto!



-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context:
http://old.nabble.com/Missing-dates--tp17760957p28548166.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Overlapping Periods

Marks, Jim
Oops! I used indate for the outdate in the aggregate. (Thanks, Brian).

** CORRECTED.

Here is a solution.

** Sample data.
NEW FILE.
DATA LIST FREE/StudyID (f8.0) InDate (ADATE10) OutDate (ADATE10).
BEGIN DATA
30006           09/20/2002       04/30/2007
30006           12/29/2006      05/31/2012
30006           11/25/2009      05/31/2012
30014           04/16/1975       03/03/1988
30014           04/21/1980       05/28/1982
30014           02/16/2001       11/24/2001
30022           02/05/1992        07/22/1995
30057           02/01/1988        11/20/1988
30057           12/15/1989      10/17/1990
30057           01/23/1992       10/18/1993
END DATA.
DATASET NAME intervals WINDOW = FRONT.

** optional if live data is presorted.
SORT CASES BY studyID indate (A).

** Identify overlapping periods.
COMPUTE sequence  = 1.
IF studyid = LAG(studyid) AND indate LE LAG(outdate) sequence =
LAG(sequence) + 1.


** create a variable to identify the start of a new overlapping period.
COMPUTE seq_start = sequence = 1.

** create a variable to number each new set of overlapping periods--
** needed to aggregate data.
FILTER BY seq_start.
RANK indate BY studyID / RANK INTO intervals.
FILTER  OFF.

** transfer the number for each new overlapping period
** down to each case in the overlapping period.
NUMERIC   #seq  (F8.0).
DO IF seq_start.
.  COMPUTE #seq = intervals.
ELSE .
.         COMPUTE intervals = #seq.
END IF .
EXECUTE .

DATASET DECLARE final_data.
AGGREGATE OUTFILE = final_data /BREAK = studyID intervals
  /indate = MIN(indate) /outdate = MAX(outdate).
DATASET ACTIVATE final_data.
LIST.

Jim Marks
Director, Market Research
x1616

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Dates, Brian
Sent: Thursday, May 13, 2010 10:22 AM
To: [hidden email]
Subject: Re: Overlapping Periods

Since I need similar syntax to assess multiple psychiatric
hospitalizations within multiple episodes of care, I was particularly
interested in this thread.  When I ran the syntax, my output was:

StudyID intervals     indate    outdate

   30006     1.000 09/20/2002 11/25/2009
   30014     1.000 04/16/1975 04/21/1980
   30014     2.000 02/16/2001 02/16/2001
   30022     1.000 02/05/1992 02/05/1992
   30057     1.000 02/01/1988 02/01/1988
   30057     2.000 12/15/1989 12/15/1989
   30057     3.000 01/23/1992 01/23/1992

I don't think the syntax solves the problem yet.

Brian

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: Thursday, May 13, 2010 10:22 AM
To: [hidden email]
Subject: Re: Overlapping Periods

Gene Maguin wrote:
>
> Jim,
>
> Thank you for pointing out my error. The code I posted doesn't yield
the
> sample output. After studying Asil's imput and output this morning, I
> realize that I didn't understand the problem that Asil had posed.
>
> Gene Maguin
>
>


And since I proposed the same solution as Gene...ditto!



-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context:
http://old.nabble.com/Missing-dates--tp17760957p28548166.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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

=====================
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
123