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>
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).
You can then reconstruct the date if you want to with:
COMPUTE newdate = DATE.MDY (mnth, day, year).
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
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.
Hi there...I have attempted to follow some very helpful advice in
converting a numeric date into the objective of an ADATE8 format:
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 day =substr(date,3,2).
I get the following error message:
>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
>This command not executed.
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:
but same error message.......hmmmmmm any suggestions........?
take care and thank you!!!