Abdul Shiyas
Abdul Shiyas

Reputation: 401

How to merge two columns of same name in sas dataset?

I have a datafile having same column names. I want to merge them without any seperator and get it in new column. But I am getting subsequent columns as var2 var3 var4 etc. How can we merge them in sas?

As I have columns of different variables with same name, for eg: my column order is name1, name2, name2,name1,name2 , we cant use var1,var2 for merging. What can we do?

My csv datafile is similar to this enter image description here

And my corresponding sasdata is enter image description here

How can we get a merged column?(column name can be "EMPLOYMENT")

Upvotes: 0

Views: 1216

Answers (1)

DWal
DWal

Reputation: 2762

Not completely sure I understand the question, but I think you want to use cats(). e.g. newvar=cats(var1,var2,var3). This concatenates the values with no separators and no leading or trailing spaces.

coalesce() is another option that will take only the first nonmissing value in the list.

Upvotes: 1

Related Questions