Date: Mon, 17 Nov 2003 10:07:12 -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: removing " character from string variable
In-Reply-To: <sfb8e099.086@MAINCF1P.cf.ac.uk>
Content-Type: text/plain; charset="us-ascii"
Hi Paul,
Here is a variation on some "find/replace" syntax that does what you
want.
--
DATA LIST fixed/v1 1-5(a).
BEGIN DATA.
"ABC"
"A"
"B"
END DATA.
LIST.
DO IF (INDEX(v1,'"')>0).
. LOOP.
. COMPUTE v1 = CONCAT(SUBSTR(v1,1,INDEX(v1,'"')-1),"",
SUBSTR(v1,INDEX(v1,'"')+1,
LENGTH(v1)-INDEX(v1,'"'))).
. END LOOP IF (INDEX(v1,'"')=0).
END IF.
EXE.
LIST.
--
Mark Casazza
Director of Academic Information
The City University of New York
555 West 57th St. Suite 1240
New York, NY 10019
phone: 212.541.0396
fax: 212.541.0372
mark.casazza@mail.cuny.edu
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf
Of
Paul Mcgeoghan
Sent: Monday, November 17, 2003 9:52 AM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: removing " character from string variable
Hi,
If I have data which starts and ends with ", how I can remove "?
"ABC"
"A"
"B"
I have tried the following which removes the " from the left as does
LTRIM.
COMPUTE COMPANY = SUBSTR(company,2,LEN(RTRIM(company))-1) .
EXECUTE .
I can't seem to remove it from the right though.
Thanks,
Paul
==================
Paul McGeoghan,
Application support specialist (Statistics and Databases),
Information Services,
Cardiff University.
Tel. 02920 (875035).
|