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 (September 1998)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 31 Aug 1998 13:16:01 -0700
Reply-To:     Jeff Capizzi <capizzij@OHSU.EDU>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From:         Jeff Capizzi <capizzij@OHSU.EDU>
Organization: OHSU
Subject:      Dale Glaser dates
Content-Type: text/plain; charset=us-ascii

You might have already solved this problem, but ...

The error message is probably telling you that 'month' 'day' and 'year' are not defined as string variables so you might want to use syntax more like:

STRING mnth (A4) day (A4) year (A4). COMPUTE mnth = SUBSTR (date, 1, 2). COMPUTE day = SUBSTR (date, 3, 2). COMPUTE year = SUBSTR (date, 5, 2). EXECUTE.

You can then reconstruct the date if you want to with:

COMPUTE newdate = DATE.MDY (mnth, day, year). EXECUTE.

The variables are string after the first bit of syntax, but they have to be converted to numeric for the compute statement. You can select the format of the date (newdate) in the define variable box.

Its also prudent to know how/if your data is padded with spaces - best to avoid any spaces. Otherwise you have to start guessing what the positions of mnth, day, and year are as substrings.

cheers ----------------------------------------------------------- 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