SPSS: String to date?

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

SPSS: String to date?

William Adams

Hi Everyone,

 

I am using Remark Office OMR to transfer text from a paper survey to SPSS.  Everything is transferring to my SPSS V.20 Grad Pack Premium perfectly, except for one thing: 

 

Dates (e.g., 04/01/1981) on the paper survey are initially appearing as 04011981 in SPSS.  When I try to change the variable type to “Date (mm/dd/yyyy)”, 04011981 becomes 10/26/1582.

 

Any idea how to fix this?

 

Thank you,

Bill

Reply | Threaded
Open this post in threaded view
|

Question regarding linking data

stace swayne
Dear List,
 
I have 3 waves of data (wave 1, wave 2, wave 3). I have people who have dropped out or died in wave 2 and wave 3. I want to identify people who have data for all three waves (Each person has a unique ID). Does someone have sample syntax that can do this?
 
All suggestions are welcomed,
 
Stace
Reply | Threaded
Open this post in threaded view
|

Re: SPSS: String to date?

Rick Oliver-3
In reply to this post by William Adams
Given the leading zero, I'm assuming it's a string value:

Compute #m=number(substr(datevar, 1,2), n2).
compute #d=number(substr(datevar(3,2),n2).
compute #y=number(substr(datevar,5), f4).
newdate=date.mdy(#m, #d, #y).
formats newdate (adate10).

There are a number of different ways to skin that particular cat.

If your are using the dialog interface, try the Date and Time wizard on the Transform menu.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]
Phone: 312.893.4922 | T/L: 206-4922




From:        William Adams <[hidden email]>
To:        [hidden email]
Date:        03/29/2012 07:18 AM
Subject:        SPSS:  String to date?
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi Everyone,
 
I am using Remark Office OMR to transfer text from a paper survey to SPSS.  Everything is transferring to my SPSS V.20 Grad Pack Premium perfectly, except for one thing:  
 
Dates (e.g., 04/01/1981) on the paper survey are initially appearing as 04011981 in SPSS.  When I try to change the variable type to “Date (mm/dd/yyyy)”, 04011981 becomes 10/26/1582.
 
Any idea how to fix this?
 
Thank you,
Bill
Reply | Threaded
Open this post in threaded view
|

Re: SPSS: String to date?

David Marso
Administrator
In reply to this post by William Adams
data list / strdate (A8).
begin data
04011981
end data
NUMERIC numdate (ADATE).
COMPUTE numdate=NUMBER(CONCAT(CHAR.SUBSTR(strdate,1,2),"/",
                              CHAR.SUBSTR(strdate,3,2),"/",
                              CHAR.SUBSTR(strdate,5)),ADATE).
LIST.

William Adams wrote
Hi Everyone,



I am using Remark Office OMR to transfer text from a paper survey to SPSS.
Everything is transferring to my SPSS V.20 Grad Pack Premium perfectly,
except for one thing:



Dates (e.g., 04/01/1981) on the paper survey are initially appearing as
04011981 in SPSS.  When I try to change the variable type to "Date
(mm/dd/yyyy)", 04011981 becomes 10/26/1582.



Any idea how to fix this?



Thank you,

Bill
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: Question regarding linking data

David Marso
Administrator
In reply to this post by stace swayne
Look at the AGGREGATE command!
stace swayne wrote
Dear List,
 
I have 3 waves of data (wave 1, wave 2, wave 3). I have people who have dropped out or died in wave 2 and wave 3. I want to identify people who have data for all three waves (Each person has a unique ID). Does someone have sample syntax that can do this?
 
All suggestions are welcomed,
 
Stace
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: Question regarding linking data

Maguin, Eugene
In reply to this post by stace swayne

Stace,

 

Method A: you have three files, wave 1, wave 2 and wave 3. Match files and use the IN subcommand. Crosstab those variables.

 

Method B: waves are already together in one file and there is a single variable in each wave that identifies whether a person was interviewed/had data. Just crosstab those variables.

 

Method C: waves are already together in one file and there is a not single variable in each wave that identifies whether a person was interviewed/had data. Bad case but not the worst. You'll have to adapt this to your specific situation but let's suppose all data are numeric and if the person was interviewed their data values are either valid or user missing. If the person was not interviewed all their data values are sysmis. Thus for any one data value, valid or user missing means an interview and sysmis means no interview. Recode the variable and crosstab.

 

Method D: The worst. Method C situation except that no user missing values were defined. All missing values are sysmis. Again, suppose all data are numeric. Suppose the wave 2 file had 1,057 data values, named a1 to zz45. Then count sysmis across all those values. Persons with no interview will have 1,057 sysmis values.

 

Gene Maguin

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of stace swayne
Sent: Thursday, March 29, 2012 10:19 AM
To: [hidden email]
Subject: Question regarding linking data

 

Dear List,

 

I have 3 waves of data (wave 1, wave 2, wave 3). I have people who have dropped out or died in wave 2 and wave 3. I want to identify people who have data for all three waves (Each person has a unique ID). Does someone have sample syntax that can do this?

 

All suggestions are welcomed,

 

Stace

Reply | Threaded
Open this post in threaded view
|

Re: Question regarding linking data

John F Hall
In reply to this post by David Marso
Difficult to answer your question without seeing a sample extract from the data.

If all 3 waves are in the same file you might be able to use COUNT on a variable common to all waves, eg:

COUNT x = commonvar1 to commonvar3 ( 1 thru <highest valid value>).
FREQ x.

. .where commonvar<n> is the same variable in each wave, then select out only those with value 3 in x.

If they're in separate files you could try Gene's MATCH FILES but use

 /KEEP commonvar1 to commonvar3.

Then do the count.

John Hall

Email:    [hidden email]
Website: www.surveyresearch.weebly.com
Skype:    surveyresearcher1
Phone:    (+33) (0) 2.33.45.91.47





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: 29 March 2012 16:54
To: [hidden email]
Subject: Re: Question regarding linking data

Look at the AGGREGATE command!

stace swayne wrote

>
> Dear List,
>
> I have 3 waves of data (wave 1, wave 2, wave 3). I have people who
> have dropped out or died in wave 2 and wave 3. I want to identify
> people who have data for all three waves (Each person has a unique
> ID). Does someone have sample syntax that can do this?
>
> All suggestions are welcomed,
>
> Stace
>


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-String-to-date-tp5603622p5604040.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: Question regarding linking data

John F Hall

Stace

 

If respondents in wave 3 are also in waves 1 and 2, you should be able to do something using ID from wave 3.  David Marso, Jon Peck and others are better qualified to advise on the best way to do this, but I suspect MATCH FILES will come into it at some point.  You could also try something like:

 

Open wave 3

 

recode ID ( 1 thru hi =3) into wave3.

 

match files etc.

 

Select if wave3 = 3.

 

John

 

 

 

From: stace swayne [mailto:[hidden email]]
Sent: 29 March 2012 19:18
To: John F Hall
Subject: Re: Question regarding linking data

 

Hi John,

 

Wave 1, 2 and 3 represent 3 separate data-sets. I am using data from  public longitudinal data-sets, people were contacted every 5 years, the people in the study are all older adults, so there is attrition due to death among other reasons. What I'm trying to due is prune the data-set so that I only have people who have data for all 3 waves of the study. Does this clarify.

 

Thanks,

 

Stace

 


From: John F Hall <[hidden email]>
To: [hidden email]
Sent: Thursday, March 29, 2012 12:24 PM
Subject: Re: Question regarding linking data


Difficult to answer your question without seeing a sample extract from the data.

If all 3 waves are in the same file you might be able to use COUNT on a variable common to all waves, eg:

COUNT x = commonvar1 to commonvar3 ( 1 thru <highest valid value>).
FREQ x.

. .where commonvar<n> is the same variable in each wave, then select out only those with value 3 in x.

If they're in separate files you could try Gene's MATCH FILES but use

/KEEP commonvar1 to commonvar3.

Then do the count.

John Hall

Email:    [hidden email]
Website: www.surveyresearch.weebly.com
Skype:    surveyresearcher1
Phone:    (+33) (0) 2.33.45.91.47





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: 29 March 2012 16:54
To: [hidden email]
Subject: Re: Question regarding linking data

Look at the AGGREGATE command!

stace swayne wrote


>
> Dear List,
>
> I have 3 waves of data (wave 1, wave 2, wave 3). I have people who
> have dropped out or died in wave 2 and wave 3. I want to identify
> people who have data for all three waves (Each person has a unique
> ID). Does someone have sample syntax that can do this?
>
> All suggestions are welcomed,
>
> Stace
>


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-String-to-date-tp5603622p5604040.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