BookmarkSubscribeRSS Feed
IvyMcKee
Calcite | Level 5

Hi there,

I have 2 columns that I want to merge into 1 column. Each column has 40,000 obs in it, all of which I want to keep. I want to merge RefPer and Quid into RefQuid.

 

All of Refper's obs are in this format: 201911, 201912 etc.

All of Quid's obs are in this format: Q12345.

 

So the obs in RefQuid should all look something like this: 201911Q12345

 

I have tried several variations of the following:

 

DATA finalval

RefQuid = CATS(RefPer, Quid);

run;

 

I keep recieving this error message: ERROR 22-322: Syntax error, expecting one of the following: A name, a quoted string, (, /. ;. _data_ _last_, _null.

 

What am I doing wrong? Is there another way to merge two columns together?

Thank you.

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Are the two variables character or numeric?

IvyMcKee
Calcite | Level 5

They are different formats... I don't mind changing them both to character formats but I also don't know how to do that.

novinosrin
Tourmaline | Level 20
DATA finalval; /*I added a semicolon here*/
Set input_dataset; /*this is missing*/
Length RefQuid  $10;
RefQuid = CATS(RefPer, Quid);

run;

 

Hi @IvyMcKee  Please see if the above makes sense to you

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1091 views
  • 2 likes
  • 4 in conversation