BookmarkSubscribeRSS Feed
ywon111
Quartz | Level 8

Hi, Is there a better way to concatenate all these variables that starting with a variable name var and a value attached?

 

Eg.

var1

var2

var3

var4

var5

 

This is what I got now, but would pick up variables like var_ which not needed.

var_conc= catx(',', of var:);

 

Thanks

 

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Provided, that your posted data is representable, you could do

 

data have;
input (var1 var_1 var2 var_2 var3 var_3)($);
datalines;
a b c d e f
;

data want;
   set have;
   var_conc = catx(',', of var1-var3);
run;
ywon111
Quartz | Level 8
Thanks but this is what I have and need:

data want;
keep skill:;
set have;

How do I concatenate all the skill variables?
ChrisNZ
Tourmaline | Level 20

Why do you change your question half-way?

 

What exactly do you want? To keep the  SKILL:  variables but not the  SKILL_:  variables? 

 

Show us the proc contents of your table, and describe exactly what you want to concatenate.

ywon111
Quartz | Level 8
I've got a long list of skill1, skill2, skill3, skill4, etc variables and need to concatenate all these variables to one. There's a variable skill_ which is not required.
Thanks

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
  • 1696 views
  • 0 likes
  • 3 in conversation