Help using Base SAS procedures

Combining Columns

Reply
N/A
Posts: 0

Combining Columns

Hi all,

I've been looking through the help guide and I can't seem to find anything on merging the data in two columns together. What I am trying to do is attach the data in column B to that in column A so I only have one column..

For example, at the moment my data is separated like:

First Name (Column A) Last Name (Column B)
John Smith

But I want:

Name (Column A)
John Smith

It's probably so simple and obvious but I can't for the life of me figure it out. I don't mind whether the advice is for the Query Builder or for code.

Thanks in advance!
Super Contributor
Super Contributor
Posts: 3,174

Re: Combining Columns

Posted in reply to deleted_user
Have a look at using the CATT function (new with SAS 9) with assigning a new SAS CHARACTER type variable in a DATA step (after declaring a LENGTH statement for the new variable).

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Combining Columns

I just worked it out. For anyones' future reference I used:

TRIM(Column A)||' '||TRIM(Column B)


Thanks for your response Scott.
Super Contributor
Super Contributor
Posts: 3,174

Re: Combining Columns

Posted in reply to deleted_user
Glad to see you worked it out. The CATX function in SAS 9 can simplify your code somewhat by handling the first variable TRIM (the second is unnecessary) and by coding your separator string as argument1 presented to CATX.

Scott
Ask a Question
Discussion stats
  • 3 replies
  • 145 views
  • 0 likes
  • 2 in conversation