LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2002)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 29 Mar 2002 10:04:44 -0500
Reply-To:     Mark Casazza <Mark.Casazza@domino1.cuny.edu>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Mark Casazza <Mark.Casazza@domino1.cuny.edu>
Subject:      Re: change mm/dd/yr to year
Comments: To: "S. Zitzer" <sallyz@u.washington.edu>
In-Reply-To:  <Pine.A41.4.44.0203281034140.49050-100000@mead4.u.washington.edu>
Content-Type: text/plain; charset="us-ascii"

Hi Sally,

Actually I had assumed that it was a date formatted variable. But, since you mentioned it, I was thinking about how to extract the year portion if it had been a string. The following works, but I'm wondering if anyone has a cleaner way of doing it--especially one that doesn't require knowing whether year is 2 or 4 digits.

-- * some data. DATA LIST FIXED /datestr 01-8 (a). BEGIN DATA 28/03/02 END DATA.

* chop into segments and extract third segment (year). COMPUTE s1 = INDEX(datestr,'/'). STRING d2 (a8). COMPUTE d2 = SUBSTR(datestr,s1+1,8-s1). COMPUTE s2 = INDEX(d2,'/'). STRING year (a2). COMPUTE year = SUBSTR(d2,s2+1). EXE.

* cleanup. MATCH FILES FILE = * /DROP = s1 s2 d2. EXE. --

Mark V. Casazza Director of Academic Information The City University of New York 555 W. 57th St. Suite 1240 New York, NY 10019

phone: 212.541.0396 fax: 212.541.0392 email: Mark.Casazza@mail.cuny.edu

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of S. Zitzer Sent: Thursday, March 28, 2002 1:42 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: change mm/dd/yr to year

Does anyone know if Chai-Ling's variable is in Date format? When he shows 28/03/02 others have assumed it is in String format. If it is in Date format there are functions to extract the month, day, and year. XDATE.YEAR will return the year from a Date variable.

Sally in Seattle

On Thu, 28 Mar 2002, Arthur J. Kendall wrote:

> Do you want a new variable that you will use for some other purpose? > Or do you just want to display the current var differently? > > > Chai-Ling Tien wrote: > > > Dear list, I know that this could be a simple and repeated question. > > Does any one knows how to change a variable with mm/dd/yr to only > > year? For example, I want to change from 28/03/02 to only 02. Any > > advise is greatly appreciated. Chia-Ling >


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