Date: Thu, 1 Dec 2011 12:12:37 -0500
Reply-To: Gene Maguin <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Gene Maguin <email@example.com>
Subject: Re: SPSS cannot treat string variables as string variables?
The immediate answer is to declare timedate as A11, because var00001 is string and you are extracting a substring (as David said). The result, therefore, will be a string. But, I’d bet that’s not where you want to wind up. That is, you want timedate to be a numeric variable with a timedate format so that you can do arithmetic with it. That requires more work.
This is untested.
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of huang jialin
Sent: Thursday, December 01, 2011 11:48 AM
Subject: SPSS cannot treat string variables as string variables?
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 may
>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.