Sas

Asked • 03/19/19

SAS: concatenate different datasets while keeping the individual data table names?

I'm trying to concatenate multiple datasets in SAS, and I'm looking for a way to store information about individual dataset names in the final stacked dataset. For eg. initial data sets are "my_data_1", "abc" and "xyz", each with columns 'var_1' and 'var_2'. I want to end up with "final" dataset with columns 'var_1', 'var_2' and 'var_3'. where 'var_3' contains values "my_data_1", "abc" or "xyz" depending on from which dataset a particular row came. (I have a cludgy solution for doing this i.e. adding table name as an extra variable in all individual datasets. But I have around 100 tables to be stacked and I'm looking for an efficient way to do this.)

1 Expert Answer

By:

Rick A. answered • 03/26/19

Tutor
5 (33)

Experienced SAS Professional

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.