Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SAS string manipulation 1

Status
Not open for further replies.

cosmid

Programmer
Feb 14, 2008
73
US
Hi,

I have a data set with the following values for the variable name:

lastname firstname
lastname firstname
lastname firstname

how do I change it to the following?

lastname firstname
lastname firstname
lastname firstname

With 1 spaces in between. I forgot what SAS function does that.

Thanks
 
Actually, I was trying to create a new variable Name with the concatenation of Lastname and Firstname. However, after I concatenated them, the spaces are different.

I used: name = lastname || ' ' || firstname

If I can concatenate them with just 1 spaces in between, it also solves my problem from above.

thanks
 
Problem solved!

I used the trim() function before I concatanated the 2 variables. That take cares of the space problem.

Now my problem is how do I remove a thread that I posted myself?
 
oh...I just got hope nobody will click on this thread then.
 
This is what the catx function in sas9 is for - It will concatenate strings and remove leading and lagging blanks.

name = catx(' ',lastname,firstname);
 
ahh..thanks! I never heard of this function. which book do you use?
 
ahh..thanks! i didn't know SAS documentation can be find online!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top