BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
6 REPLIES 6
Reeza
Super User
Look up the SAS functions trim() and left(), right() is also useful to know.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
DCL
Obsidian | Level 7 DCL
Obsidian | Level 7
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
Ksharp
Super User
Function : strip(ZORTNAME) would be helpful...



Ksharp
deleted_user
Not applicable
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??
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1352 views
  • 0 likes
  • 5 in conversation