BookmarkSubscribeRSS Feed
AliMN
Calcite | Level 5

Hello,

My dataset (ABC) contain the following columns: account1, account2 and I want to combine (concatenate) account1 and account2 columns and create another column called account1_2. Here is the how the dataset (ABC) is look like now:

account1

account2

1200

3000

My final result (wanted) should be look like:

account1

account2

account1_2

1200

3000

12003000

Here is my code but for some reason, I’m getting an error message.

Data wanted;

Set ABC;

length Account1_2 $10;

Account1_2 = catx('', Account1, Account2);

run;

Any help is appreciated,

4 REPLIES 4
data_null__
Jade | Level 19

what is the error?

AliMN
Calcite | Level 5

I got the answer I was expecting but my only problem now is, I want to get rid off the space between the two numbers under account1_2 column to make it 12003000: here's my result now:

account1

account2

account1_2

1200

3000

1200 3000

Thanks in advance

RichardinOz
Quartz | Level 8

Use the cats() function

Richard in NZ


AliMN
Calcite | Level 5

Thanks, RichardinOz. greatly it worked for me. Here's how I used cats() function

Account1_2 = cats(Account1, Account2);

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 1524 views
  • 0 likes
  • 3 in conversation