Date: Wed, 31 Oct 2001 16:09:56 +0000
Reply-To: "R. Allan Reese" <R.A.Reese@GRI.HULL.AC.UK>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "R. Allan Reese" <R.A.Reese@GRI.HULL.AC.UK>
Subject: Date conversion and simpler syntax
Content-Type: TEXT/PLAIN; charset=US-ASCII
On Wed, 31 Oct 2001, Cohen,Diane wrote:
> Questions are frequently posed for which I would like answers. I used
> to save the replies, even tho I might not have an immediate need for them.
> I stopped doing this because often responders pose such complex solutions
[RAR] I still save some replies, but also rely on being to access the
archive. It seems old fashioned, but this is still best done by an email
enquiry, for which I keep this template:
search "structural zero" in spssx-l since 98/01/01
I like the sentiment in Diane's comment though. It seems to me perverse
that although packages were devised to remove the need for ad hoc one-off
programming, people insist on developing them in ways that make
programming more essential and more obscure: scripts, VBA and BBC Basic
(where complete beginners wrote machine code) all being cases in point.
Diane was commenting on answers to:
> > Sent: Tuesday, October 30, 2001 12:02 PM
> > Jim Marks asked: I have a text file with dates in the format
> > YYYYMMDD. I can import this as a number, but I would like to
> > convert it to an actual date.
One proposed solution is
> COMPUTE date =
> FORMATS date (ADATE10).
But if the value is read as an integer number, the fields can be extracted
without type conversion. The expressions can be nested in one expression,
but I prefer Diane's dictum to make the layout clearer. The intermediate
variables can be deleted after use, or could be temporary #day etc.
FORMATS date (ADATE10).
compute day =mod(indate,100) .
compute month=mod( trunc(indate/100),100).
compute yr =trunc(indate/10000).
COMPUTE date = date.dmy( day, month, yr).
Allan Reese (not downgrading to XP)