Combining Date and Service Fields so its sortable

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

Combining Date and Service Fields so its sortable

GeorgeH

Hi, all

 

Sorry if this email shows up twice. I am having problem with my email.


This may seem like an odd question and you guys may have a better way of doing this. I have files of clients that have had many different services across time. I just want to analyze the time variables but do so in a way that the time reflects the service. Clients can have 0 – 27 possible different time data points.  One service does not build on another service. For example, a client does not necessarily go through training, before intervention before employment. I will be restructuring the data into long format.  I want to be able to sort the dates and have the time reflect the order of the service for each client. If I just have the intervention name, I can’t tell which service came before another service. If I use the date, I can’t tell which service the dates represent. For example:

 

111 Training Intervention Intervention Training Training Employment Employment Intervention Employment

 

Other than pre-sorting prior to restructuring, which I don't want to do because I want to track the date files, is there a way to do this?

 

ClientID

Training

Intervention

Employment

111

3/4/2005

6/1/2005

9/21/2005

111

7/5/2005

7/1/2005

10/1/2005

111

9/7/2005

10/15/2006

12/9/2005

222

5/27/2009

7/23/2009

5/15/2009

222

8/14/2009

10/1/2009

1/23/2009

333

12/1/2009

1/15/2010

5/2/2008

333

2/10/2010

3/23/2010

4/15/2009

333

4/21/2010

6/1/2010

8/25/2010

333

7/15/2010

9/21/2010

2/1/2011

 

Thanks

 

George

 

Reply | Threaded
Open this post in threaded view
|

Re: Combining Date and Service Fields so its sortable

Maguin, Eugene

Are you saying that the incoming data file has four variables (ClientID, Training, Intervention, Employment)?

 

And you want to restructure the file to something like this?

 

ClientID ServiceType Date

111         Training                3/4/2005

111         Intervention      6/1/2005

111         Intervention      7/1/2005

111         Training                7/5/2005

111         Training                9/7/2005

111         Employment      9/21/2005

111         Employment      10/1/2005

111         Employment      12/9/2005

111         Intervention      10/15/2006

 

If so, I think but I’m not sure that you will first need to do a Casestovars to get one record per id and then a Varstocases to get 9 (or however many there) records per id. And, I kind of think there may need to be some work in between the Casestovars and the Varstocases to get the Varstocases to fall out into three columns but I’d need to work with your example data to check that out.

 

Gene Maguin

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of George Hamlin
Sent: Monday, May 06, 2013 1:48 PM
To: [hidden email]
Subject: Combining Date and Service Fields so its sortable

 

Hi, all

 

Sorry if this email shows up twice. I am having problem with my email.

 

This may seem like an odd question and you guys may have a better way of doing this. I have files of clients that have had many different services across time. I just want to analyze the time variables but do so in a way that the time reflects the service. Clients can have 0 – 27 possible different time data points.  One service does not build on another service. For example, a client does not necessarily go through training, before intervention before employment. I will be restructuring the data into long format.  I want to be able to sort the dates and have the time reflect the order of the service for each client. If I just have the intervention name, I can’t tell which service came before another service. If I use the date, I can’t tell which service the dates represent. For example:

 

111 Training Intervention Intervention Training Training Employment Employment Intervention Employment

 

Other than pre-sorting prior to restructuring, which I don't want to do because I want to track the date files, is there a way to do this?

 

ClientID

Training

Intervention

Employment

111

3/4/2005

6/1/2005

9/21/2005

111

7/5/2005

7/1/2005

10/1/2005

111

9/7/2005

10/15/2006

12/9/2005

222

5/27/2009

7/23/2009

5/15/2009

222

8/14/2009

10/1/2009

1/23/2009

333

12/1/2009

1/15/2010

5/2/2008

333

2/10/2010

3/23/2010

4/15/2009

333

4/21/2010

6/1/2010

8/25/2010

333

7/15/2010

9/21/2010

2/1/2011

 

Thanks

 

George

 

Reply | Threaded
Open this post in threaded view
|

Re: Combining Date and Service Fields so its sortable

David Marso
Administrator
In reply to this post by GeorgeH
George,
  It is unclear how the first data representation maps to the second wrt dates being associated with the different events.  Perhaps posting or attaching an actual example of the data might be helpful?
David

GeorgeH wrote
Hi, all



Sorry if this email shows up twice. I am having problem with my email.


This may seem like an odd question and you guys may have a better way of
doing this. I have files of clients that have had many different services
across time. I just want to analyze the time variables but do so in a way
that the time reflects the service. Clients can have 0 – 27 possible
different time data points.  One service does not build on another service.
For example, a client does not necessarily go through training, before
intervention before employment. I will be restructuring the data into long
format.  I want to be able to sort the dates and have the time reflect the
order of the service for each client. If I just have the intervention name,
I can’t tell which service came before another service. If I use the date,
I can’t tell which service the dates represent. For example:



111 Training Intervention Intervention Training Training Employment
Employment Intervention Employment



Other than pre-sorting prior to restructuring, which I don't want to do
because I want to track the date files, is there a way to do this?



ClientID

Training

Intervention

Employment

111

3/4/2005

6/1/2005

9/21/2005

111

7/5/2005

7/1/2005

10/1/2005

111

9/7/2005

10/15/2006

12/9/2005

222

5/27/2009

7/23/2009

5/15/2009

222

8/14/2009

10/1/2009

1/23/2009

333

12/1/2009

1/15/2010

5/2/2008

333

2/10/2010

3/23/2010

4/15/2009

333

4/21/2010

6/1/2010

8/25/2010

333

7/15/2010

9/21/2010

2/1/2011



Thanks



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

Re: Combining Date and Service Fields so its sortable

Melissa Ives
In reply to this post by Maguin, Eugene

George,

I wonder if it would be simple enough to save three files (a training file, an intervention file and an employment file) with just the id and the date, calculate a type and add them all together.

I think Date is a reserved word so I called the new variables SDate (service date).

Something like this….(untested.

 

Save outfile=’<pathname>/Training.sav’/keep=clientid Training.

Save outfile=’<pathname>/Intervention.sav’/keep=clientid Intervention.

Save outfile=’<pathname>/Employment.sav’/keep=clientid Employment.

 

Get file=’<pathname>/Training.sav’.

Dataset name training.

Rename Training=SDate.

Compute ServiceType=1.

 

Get file=’<pathname>/Intervention.sav’.

Dataset name Intervention.

Rename Intervention=SDate.

Compute ServiceType=2.

 

Get file=’<pathname>/ Employment.sav’.

Dataset name Employment.

Rename Employment =SDate.

Compute ServiceType=3.

 

Add files file=Training/File=Intervention/File=Employment.

Dataset name combo.

Val labels ServiceType 1 ‘Training’ 2 ‘Intervention’ 3 ‘Employment’.

Dataset activate combo.

Sort cases by clientid SDate.

 

Melissa

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Maguin, Eugene
Sent: Tuesday, May 07, 2013 10:11 AM
To: [hidden email]
Subject: Re: [SPSSX-L] Combining Date and Service Fields so its sortable

 

Are you saying that the incoming data file has four variables (ClientID, Training, Intervention, Employment)?

 

And you want to restructure the file to something like this?

 

ClientID ServiceType Date

111         Training                3/4/2005

111         Intervention      6/1/2005

111         Intervention      7/1/2005

111         Training                7/5/2005

111         Training                9/7/2005

111         Employment      9/21/2005

111         Employment      10/1/2005

111         Employment      12/9/2005

111         Intervention      10/15/2006

 

If so, I think but I’m not sure that you will first need to do a Casestovars to get one record per id and then a Varstocases to get 9 (or however many there) records per id. And, I kind of think there may need to be some work in between the Casestovars and the Varstocases to get the Varstocases to fall out into three columns but I’d need to work with your example data to check that out.

 

Gene Maguin

 

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of George Hamlin
Sent: Monday, May 06, 2013 1:48 PM
To: [hidden email]
Subject: Combining Date and Service Fields so its sortable

 

Hi, all

 

Sorry if this email shows up twice. I am having problem with my email.

 

This may seem like an odd question and you guys may have a better way of doing this. I have files of clients that have had many different services across time. I just want to analyze the time variables but do so in a way that the time reflects the service. Clients can have 0 – 27 possible different time data points.  One service does not build on another service. For example, a client does not necessarily go through training, before intervention before employment. I will be restructuring the data into long format.  I want to be able to sort the dates and have the time reflect the order of the service for each client. If I just have the intervention name, I can’t tell which service came before another service. If I use the date, I can’t tell which service the dates represent. For example:

 

111 Training Intervention Intervention Training Training Employment Employment Intervention Employment

 

Other than pre-sorting prior to restructuring, which I don't want to do because I want to track the date files, is there a way to do this?

 

ClientID

Training

Intervention

Employment

111

3/4/2005

6/1/2005

9/21/2005

111

7/5/2005

7/1/2005

10/1/2005

111

9/7/2005

10/15/2006

12/9/2005

222

5/27/2009

7/23/2009

5/15/2009

222

8/14/2009

10/1/2009

1/23/2009

333

12/1/2009

1/15/2010

5/2/2008

333

2/10/2010

3/23/2010

4/15/2009

333

4/21/2010

6/1/2010

8/25/2010

333

7/15/2010

9/21/2010

2/1/2011

 

Thanks

 

George

 



PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.
Reply | Threaded
Open this post in threaded view
|

Re: Combining Date and Service Fields so its sortable

GeorgeH
In reply to this post by GeorgeH



Tamra Boyce
Principal Planning Analyst 
Hennepin County
Research, Planning and Development (238)
300 South 6th Street
Minneapolis, MN 55487
PH:(612) 348-7059
Blackberry 612-432-7701


The plural of anecdote is not data.
~ Roger Brinner







From: "Maguin, Eugene" <[hidden email]>
Date: 05/07/2013 10:19 AM
Subject: Re: Combining Date and Service Fields so its sortable
Sent by: "SPSSX(r) Discussion" <[hidden email]>



Are you saying that the incoming data file has four variables (ClientID, Training, Intervention, Employment)?
 
Gene

I don't want to restructure it like that - at least not yet. I'm not at that point yet. To be honest, I'm still working through the logic of this whole thing.

I want to recode the data variable, for example 3/4/2005 to a 3/4/2005T to note that a training occurred on that date - thus the date also becomes the service type. But I want to keep the sort capability of the date. I want to combine the service type with the date and then sort that date/service to get a kind of service pathway.

So it would look like this for client 111:
3/4/2005T
6/1/2005I
7/1/2005I
7/5/2005T
9/7/2005T
9/21/2005E

I really don't want to lose that date sort ability because the date order matters. Thinking more about this, I might just sort by ID then the date, concatenate the date and service type, and then restructure - which would give me my "service pathway".

George

____________________________________________________________________
From: "Maguin, Eugene" <[hidden email]>
Date: 05/07/2013 10:19 AM
Subject: Re: Combining Date and Service Fields so its sortable
Sent by: "SPSSX(r) Discussion" <[hidden email]>



Are you saying that the incoming data file has four variables (ClientID, Training, Intervention, Employment)?

And you want to restructure the file to something like this?
 
ClientID ServiceType Date
111         Training                3/4/2005
111         Intervention      6/1/2005
111         Intervention      7/1/2005
111         Training                7/5/2005
111         Training                9/7/2005
111         Employment      9/21/2005
111         Employment      10/1/2005
111         Employment      12/9/2005
111         Intervention      10/15/2006
 
If so, I think but I’m not sure that you will first need to do a Casestovars to get one record per id and then a Varstocases to get 9 (or however many there) records per id. And, I kind of think there may need to be some work in between the Casestovars and the Varstocases to get the Varstocases to fall out into three columns but I’d need to work with your example data to check that out.
 
Gene Maguin
 
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of George Hamlin
Sent: Monday, May 06, 2013 1:48 PM
Subject: Combining Date and Service Fields so its sortable
 
Hi, all
 
Sorry if this email shows up twice. I am having problem with my email.
 
This may seem like an odd question and you guys may have a better way of doing this. I have files of clients that have had many different services across time. I just want to analyze the time variables but do so in a way that the time reflects the service. Clients can have 0 – 27 possible different time data points.  One service does not build on another service. For example, a client does not necessarily go through training, before intervention before employment. I will be restructuring the data into long format.  I want to be able to sort the dates and have the time reflect the order of the service for each client. If I just have the intervention name, I can’t tell which service came before another service. If I use the date, I can’t tell which service the dates represent. For example:
 
111 Training Intervention Intervention Training Training Employment Employment Intervention Employment
 
Other than pre-sorting prior to restructuring, which I don't want to do because I want to track the date files, is there a way to do this?
 
ClientID Training Intervention Employment
111 3/4/2005 6/1/2005 9/21/2005
111 7/5/2005 7/1/2005 10/1/2005
111 9/7/2005 10/15/2006 12/9/2005
222 5/27/2009 7/23/2009 5/15/2009
222 8/14/2009 10/1/2009 1/23/2009
333 12/1/2009 1/15/2010 5/2/2008
333 2/10/2010 3/23/2010 4/15/2009
333 4/21/2010 6/1/2010 8/25/2010
333 7/15/2010 9/21/2010 2/1/2011
 
Thanks
 
George
 

Reply | Threaded
Open this post in threaded view
|

Re: Combining Date and Service Fields so its sortable

David Marso
Administrator
In reply to this post by Melissa Ives
Assuming (ESPSS here) that the table presented is the actual initial data structure rather than the result from some unknown structure (in latter case please redefine actual problem).  The problem can be resolved very simply without intermediate files.
--
DATA LIST FREE/ ClientID (F3) Training (ADATE) Intervention  (ADATE) Employment  (ADATE) .
BEGIN DATA
111 03/04/2005 06/01/2005 09/21/2005
111 07/05/2005 07/01/2005 10/01/2005
111 09/07/2005 10/15/2006 12/09/2005
222 05/27/2009 07/23/2009 05/15/2009
222 08/14/2009 10/01/2009 01/23/2009
333 12/01/2009 01/15/2010 05/02/2008
333 02/10/2010 03/23/2010 04/15/2009
333 04/21/2010 06/01/2010 08/25/2010
333 07/15/2010 09/21/2010 02/01/2011
END DATA.

VARSTOCASES
  /MAKE Dates FROM Training Intervention Employment /INDEX=Service(Dates)  /KEEP=ClientID .
SORT CASES BY ClientID Dates.
LIST.

ClientID Service           Dates

   111   Training     03/04/2005
   111   Intervention 06/01/2005
   111   Intervention 07/01/2005
   111   Training     07/05/2005
   111   Training     09/07/2005
   111   Employment   09/21/2005
   111   Employment   10/01/2005
   111   Employment   12/09/2005
   111   Intervention 10/15/2006
   222   Employment   01/23/2009
   222   Employment   05/15/2009
   222   Training     05/27/2009
   222   Intervention 07/23/2009
   222   Training     08/14/2009
   222   Intervention 10/01/2009
   333   Employment   05/02/2008
   333   Employment   04/15/2009
   333   Training     12/01/2009
   333   Intervention 01/15/2010
   333   Training     02/10/2010
   333   Intervention 03/23/2010
   333   Training     04/21/2010
   333   Intervention 06/01/2010
   333   Training     07/15/2010
   333   Employment   08/25/2010
   333   Intervention 09/21/2010
   333   Employment   02/01/2011


Number of cases read:  27    Number of cases listed:  27
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Combining Date and Service Fields so its sortable

David Marso
Administrator
In reply to this post by GeorgeH
"To be honest, I'm still working through the logic of this whole thing."
When you sort out your inputs and desired outputs get back to us!
NOTE the format you propose id NOT SORTABLE!! Rethink that.
OTOH:  There is an SDATE (sortable date) format yyyy-mm-dd
I would keep the date and service as separate variables (see my solution below or above ).
Doing otherwise simply opens you to a world of pain!

GeorgeH wrote
Gene

I don't want to restructure it like that - at least not yet. I'm not at
that point yet. To be honest, I'm still working through the logic of this
whole thing.

I want to recode the data variable, for example 3/4/2005 to a 3/4/2005T to
note that a training occurred on that date - thus the date also becomes the
service type. But I want to keep the sort capability of the date. I want to
combine the service type with the date and then sort that date/service to
get a kind of service pathway.

So it would look like this for client 111:
3/4/2005T
6/1/2005I
7/1/2005I
7/5/2005T
9/7/2005T
9/21/2005E

I really don't want to lose that date sort ability because the date order
matters. Thinking more about this, I might just sort by ID then the date,
concatenate the date and service type, and then restructure - which would
give me my "service pathway".

George

____________________________________________________________________
From: "Maguin, Eugene" <[hidden email]>
To: [hidden email]
Date: 05/07/2013 10:19 AM
Subject: Re: Combining Date and Service Fields so its sortable
Sent by: "SPSSX(r) Discussion" <[hidden email]>



Are you saying that the incoming data file has four variables (ClientID,
Training, Intervention, Employment)?

And you want to restructure the file to something like this?

ClientID ServiceType Date
111         Training                3/4/2005
111         Intervention      6/1/2005
111         Intervention      7/1/2005
111         Training                7/5/2005
111         Training                9/7/2005
111         Employment      9/21/2005
111         Employment      10/1/2005
111         Employment      12/9/2005
111         Intervention      10/15/2006

If so, I think but I’m not sure that you will first need to do a
Casestovars to get one record per id and then a Varstocases to get 9 (or
however many there) records per id. And, I kind of think there may need to
be some work in between the Casestovars and the Varstocases to get the
Varstocases to fall out into three columns but I’d need to work with your
example data to check that out.

Gene Maguin

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
George Hamlin
Sent: Monday, May 06, 2013 1:48 PM
To: [hidden email]
Subject: Combining Date and Service Fields so its sortable

Hi, all

Sorry if this email shows up twice. I am having problem with my email.

This may seem like an odd question and you guys may have a better way of
doing this. I have files of clients that have had many different services
across time. I just want to analyze the time variables but do so in a way
that the time reflects the service. Clients can have 0 – 27 possible
different time data points.  One service does not build on another service.
For example, a client does not necessarily go through training, before
intervention before employment. I will be restructuring the data into long
format.  I want to be able to sort the dates and have the time reflect the
order of the service for each client. If I just have the intervention name,
I can’t tell which service came before another service. If I use the date,
I can’t tell which service the dates represent. For example:

111 Training Intervention Intervention Training Training Employment
Employment Intervention Employment

Other than pre-sorting prior to restructuring, which I don't want to do
because I want to track the date files, is there a way to do this?

ClientID Training Intervention Employment
111 3/4/2005 6/1/2005 9/21/2005
111 7/5/2005 7/1/2005 10/1/2005
111 9/7/2005 10/15/2006 12/9/2005
222 5/27/2009 7/23/2009 5/15/2009
222 8/14/2009 10/1/2009 1/23/2009
333 12/1/2009 1/15/2010 5/2/2008
333 2/10/2010 3/23/2010 4/15/2009
333 4/21/2010 6/1/2010 8/25/2010
333 7/15/2010 9/21/2010 2/1/2011

Thanks

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

Automatic reply: Combining Date and Service Fields so its sortable

Fuller, Matthew
I will be out of the office until May 13th with limited access to e-mail.

=====================
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: Combining Date and Service Fields so its sortable

GeorgeH
In reply to this post by GeorgeH
I appreciate all the syntax and help I received both on and off-line - and I have been given a number of things to think about. I'll work through the solutions offered to see what works best for me. 

Thanks to all those that offered help.

George