Date: Mon, 17 Nov 2003 13:00:03 -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: <B7555B813C9CD311965B00508B5BC64B6142E3@>
Content-Type: text/plain; charset="iso-8859-1"
John: take a close look at the string that results from your code. In
removing one character you're actually inserting another character, a
null. This is really obvious if you put a couple of (") before the
"letters" in the example (or place one between two letters). For some
text strings this may not make a lot of difference, but if you're
working with a variable that you need to match on, the nulls will be
part of the string you're trying to match so the string ABC would not
match the string nullABCnull.
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
JC Dashper
Sent: Monday, November 17, 2003 10:30 AM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Re: removing " character from string variable
try this. its a very useful adaptable utility.
data list fixed/ name (a8).
begin data.
"ABC"
"A"
"B"
end data.
string name2 (a8).
loop #x=1 to 8.
do if ~(substr(name,#x,1)='"').
compute substr(name2,#x,1)=substr(name,#x,1).
end if.
end loop.
exec.
*if you don't want the original variable, then.
match files file=*/rename (name name2=x name )/drop x.
exec.
OK?
John Dashper
-----Original Message-----
From: Paul Mcgeoghan [mailto:Mcgeoghan@Cardiff.ac.uk]
Sent: 17 November 2003 14:52
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).