Help using Base SAS procedures

Space Removing..Need Help!

Reply
N/A
Posts: 0

Space Removing..Need Help!

Hi;

I have a dataset like this:

ID NAME ZORTNAME
1 X ABC DEF
2 Y WER DS
3 Z XCF TRDS

in the id and name column there is no problem. But in the ZORTNAME column
there are many spaces in front of the records and also have unnecesary spaces
at the end of the datas. So i want to remove them. But by doing them i want
to protect the spaces between words. For example: In between ABC and DEF there is a space which should not be removed.

So the final output will look like this:

ID NAME ZORTNAME
1 X (no space)ABC DEF(no space)
2 Y (no space)WER DS(no space)
3 Z (no space)XCF TRDS(no space)

Could you please help me about this issue??

Best Regards,
Cakcan
Super User
Posts: 19,772

Re: Space Removing..Need Help!

Posted in reply to deleted_user
Look up the SAS functions trim() and left(), right() is also useful to know.
Super Contributor
Super Contributor
Posts: 3,174

Re: Space Removing..Need Help!

Using a DATA step approach, consider using the SAS function COMPBL to scrub your SAS variable content after INPUT.

Kindly, before posting, suggest you consider the appropriate forum - not just the first one in the list -- yes, there are other posters that do the same but I am hoping it's worth the suggestion.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

+compbl function data step scrub site:sas.com Message was edited by: sbb
Contributor DCL
Contributor
Posts: 40

Re: Space Removing..Need Help!

in addition to the above solutions..
if ur sas version is 9 or later, strip function could serve the purpose. It is equivalent to trim(left());

-D
Super User
Posts: 10,023

Re: Space Removing..Need Help!

Posted in reply to deleted_user
Function : strip(ZORTNAME) would be helpful...



Ksharp
N/A
Posts: 0

Re: Space Removing..Need Help!

Posted in reply to deleted_user
I guess it doesn't work.
I am sending a sample row of my records. Please check it out.

example:

Auchan 93000 BOBIGNY
Auchan 93007 LEBLAN CMESNIL

There are some blanks/space or some special chars at the end of the records (for example: at the and of the "Auchan" which i dont understand. Trim compress strip and other functions doesnt seem to work to remove the blanks.
If you double click on the "Auchan" record it selects more than the record including so many spaces.

So i could not remove it.
Some one have any idea??
Super Contributor
Super Contributor
Posts: 3,174

Re: Space Removing..Need Help!

Posted in reply to deleted_user
To the OP: Your reply: "I guess it doesn't work."

Please share whatever SAS code doesn't work - included in a post-reply but within the SAS-generated log (not just your code). And include some type of additional diagnostic revealing statement, such as below:

PUTLOG _ALL_;

This information will help others who want to help you with the problem/post.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 6 replies
  • 484 views
  • 0 likes
  • 5 in conversation