user3417415
user3417415

Reputation: 11

how to create a concatened variable from many variables in sas

I have many variables (about 100), and most of the variable value is missing. i want to concatenate all the 104 variables' values to create a new variable for each record. Are there any easy way to do this without type in the 104 variable name?

Upvotes: 1

Views: 317

Answers (1)

Joe
Joe

Reputation: 63424

You can use any of the variable name shortcuts with the CAT family of functions. You don't provide much information on your variables, so there are a few different choices depending on details like character/numeric, what you want missing to show up as, etc.; but here's the simple answer.

data want;
set have;
totalvar = cats(of var1--var104);
run;

OPTIONS MISSING=' '; might be helpful to make numeric missings turn into spaces. If you have an array for your variables, you can use cats(of yourarray[*]) as a shortcut.

Upvotes: 3

Related Questions