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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1454 views
  • 0 likes
  • 3 in conversation
OSZAR »