LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 1998)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 28 Aug 1998 11:35:40 -0700
Reply-To:   Dale Glaser <dale.glaser@SHARP.COM>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From:   Dale Glaser <dale.glaser@SHARP.COM>
Subject:   string variables and substr function
Content-Type:   text/plain; charset=US-ASCII

Hi there...I have attempted to follow some very helpful advice in converting a numeric date into the objective of an ADATE8 format:

DATE 11996 11295 91295 90495

of which I did find out that the leading zeros were truncated (data was entered in dBase3)......so in attempting to create a year variable I employed the following strategy:

...I converted the numeric date into a A6 length string variable (date), then used the following syntax:

compute month=substr(date,1,2). compute day =substr(date,3,2). compute year=substr(date,5,2). execute.

I get the following error message:

compute month=substr(date,1,2).

>Error # 4309 in column 256. 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 >function. >This command not executed.

execute.

For some reason, the variable "date", which was indeed converted into a string variable, is not being recognized as such.....I have tried multiple strategies, including keeping the variable numeric and attempting to segment it into month, day, and year accordingly, but it seems that with SPSS you have to start with a string variable in order to do that....I thought possibly the problem was the lack of leading zeros, so I attempted using options such as:

compute newdate=LPAD(date,1,'0'). execute.

but same error message.......hmmmmmm any suggestions........?

take care and thank you!!!

dale glaser


Back to: Top of message | Previous page | Main SPSSX-L page