Need to remove a leading space without removing embedded spaces

Need to remove a leading space without removing embedded spaces

Post by bshillin » Fri, 10 Dec 2004 05:38:31


Dave,

Try using the trim function, like so:

newcity = trim(left(city));

HTH

Brian

-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of David
Fickbohm
Sent: Wednesday, December 08, 2004 3:39 PM
To: XXXX@XXXXX.COM
Subject: Need to remove a leading space without removing embedded spaces

People,
I have a character variable containing city names. The problem is about
half of them have a leading space. Some of the city names have a space
inbedded in the name. So if I use compress it removes the embedded as well
as the leading spaces. I would very much appreciate an idea to start me in
the right direction.
Thanks
Dave


Dave Fickbohm
Data Mining Analyst
Homegain+
2450 45th St.
Emeryville, CA, 94608
Phone 510 655 0800 ext 4151
 
 
 

Need to remove a leading space without removing embedded spaces

Post by David » Fri, 10 Dec 2004 05:39:14

People,
I have a character variable containing city names. The problem is about
half of them have a leading space. Some of the city names have a space
inbedded in the name. So if I use compress it removes the embedded as well
as the leading spaces. I would very much appreciate an idea to start me in
the right direction.
Thanks
Dave


Dave Fickbohm
Data Mining Analyst
Homegain+
2450 45th St.
Emeryville, CA, 94608
Phone 510 655 0800 ext 4151

 
 
 

Need to remove a leading space without removing embedded spaces

Post by diski » Fri, 10 Dec 2004 05:42:05

David,

Use the left function to left justify the strings:
cityname=left(cityname);

HTH,
Dennis Diskin


People,
I have a character variable containing city names. The problem is about
half of them have a leading space. Some of the city names have a space
inbedded in the name. So if I use compress it removes the embedded as well
as the leading spaces. I would very much appreciate an idea to start me in
the right direction.
Thanks
Dave


Dave Fickbohm
Data Mining Analyst
Homegain+
2450 45th St.
Emeryville, CA, 94608
Phone 510 655 0800 ext 4151
 
 
 

Need to remove a leading space without removing embedded spaces

Post by mbrate » Fri, 10 Dec 2004 06:53:30

You may want to try 2 functions:

trim(Left( youraddressvar))



-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of
David Fickbohm
Sent: Wednesday, December 08, 2004 3:39 PM
To: XXXX@XXXXX.COM
Subject: Need to remove a leading space without removing embedded spaces

People,
I have a character variable containing city names. The problem is about
half of them have a leading space. Some of the city names have a space
inbedded in the name. So if I use compress it removes the embedded as
well
as the leading spaces. I would very much appreciate an idea to start me
in
the right direction.
Thanks
Dave


Dave Fickbohm
Data Mining Analyst
Homegain+
2450 45th St.
Emeryville, CA, 94608
Phone 510 655 0800 ext 4151


***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************
 
 
 

Need to remove a leading space without removing embedded spaces

Post by jim1sta » Fri, 10 Dec 2004 20:09:42

Hi David,

Try COMPBL. See your docs about it.

Regards - Jim.
On Wed, 8 Dec 2004 12:39:14 -0800, David Fickbohm < XXXX@XXXXX.COM >
 
 
 

Need to remove a leading space without removing embedded spaces

Post by venky.chak » Sat, 11 Dec 2004 23:55:36

I have seen the suggestion to use TRIM along with LEFT. If the sole
objective is to get rid of the leading spaces then TRIM really does
nothing. Once the spaces are TRIMMed at the end, SAS again pads those
spaces with blanks before storage.

The number of blanks = Declared length of the variable - length(variable)

LEFT alone should be sufficient. However, if you are doing something on the
fly, TRIM might be needed.