Date: Thu, 1 Dec 2011 13:46:43 -0800
Reply-To: David Marso <email@example.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: David Marso <firstname.lastname@example.org>
Subject: Re: SPSS cannot treat string variables as string variables?
Content-Type: text/plain; charset=us-ascii
"I have difficult transforming time format into military time.".....
DATA LIST / strDate (A19).
Jun 22 2010 6:23AM
Apr 11 2011 3:16PM
Nov 1 2010 10:52PM
Aug 11 2011 12:05PM
IF ( SUBSTR(strDate,18,2)="PM" AND XDATE.HOUR(TimePart) < 12 ) TimePart =
FORMATS DATEPart (DATE11).
FORMATS TimePart (Time5).
FORMATS DateTime (DateTime).
STRDATE DATEPART TIMEPART DATETIME
Jun 22 2010 6:23AM 22-JUN-2010 6:23 22-JUN-2010 06:23:00
Apr 11 2011 3:16PM 11-APR-2011 15:16 11-APR-2011 15:16:00
Nov 1 2010 10:52PM 01-NOV-2010 22:52 01-NOV-2010 22:52:00
Aug 11 2011 12:05PM 11-AUG-2011 12:05 11-AUG-2011 12:05:00
Number of cases read: 4 Number of cases listed: 4
huang jialin wrote
> The same variable is as following. But I want to calculate the different
> between time. I have difficult transforming time format into military
> Jun 22 2010 6:23AM
> Apr 11 2011 3:16PM
> Nov 1 2010 10:52PM
> Aug 11 2011 12:05PM
> I tried the CTIME.MINUTES () function, like compute time_diff=
> How can I fix the problem of time difference?
> On Thu, Dec 1, 2011 at 12:00 PM, huang jialin <huangpsych@> wrote:
>> Thanks all for your quick responses. The Declare line works.
>> To Gene, I do want the date reformatted. Thanks for the tips.
>> Thank you again.
>> On Thu, Dec 1, 2011 at 11:15 AM, Rick Oliver <oliverr@.ibm> wrote:
>>> You have to declare the new string variable first:
>>> string timedate (a11).
>>> But there are relatively simple ways to convert the original string to a
>>> real date.
>>> Rick Oliver
>>> Senior Information Developer
>>> Business Analytics (SPSS)
>>> E-mail: oliverr@.ibm | Phone: 312.893.4922 | T/L: 206-4922
>>> From: huang jialin <huangpsych@>
>>> To: SPSSX-L@.uga
>>> Date: 12/01/2011 10:50 AM
>>> Subject: SPSS cannot treat string variables as string variables?
>>> Sent by: "SPSSX(r) Discussion" <SPSSX-L@.uga>
>>> I imported data from SQL sever by ODBC. There is a string variable,
>>> formatted as following:
>>> Jun 22 2010 6:23AM
>>> Apr 11 2011 3:16PM
>>> Nov 1 2010 10:52PM
>>> Aug 11 2011 12:05PM
>>> I tried to pull out the date only, by using substr() function in SPSS.
>>> Thus, my syntax is as below:
>>> COMPUTE timedate=substr(var00001, 1, 11).
>>> But I kept on having warning like this:
>>> >Error # 4309 in column 1024. Text: (End of Command)
>>> >Invalid combination of data types in an assignment. Character strings
>>> >only be assigned to string variables. Numeric and logical quantities
>>> may only
>>> >be assigned to numeric variables. Consider using the STRING or NUMBER
>>> >Execution of this command stops.
>>> However, in the variable view, it is a string variable. How can I solve
>>> this problem?
>>> Thank you very much.
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-cannot-treat-string-variables-as-string-variables-tp5039329p5040001.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
For a list of commands to manage subscriptions, send the command