BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
learner_sas
Quartz | Level 8

Hello Everybody,

I want to combine different datasets which have similar name or started with same names. For example. I have dsn_1,dsn_2,dsn_3..............,dsn_99 and I want to set all of the datasets into one. Variables have same attributes and names across the datasets.


I am using data final;  set dsn_1 dsn_2 dsn_3 dsn4...........dsn5;run; or proc sql with union all options. I been doing this but it takes long time since I have to combine significant number of datasets.  I am wondering if there is a easier way so that I do not have to change datasets name each time I have new data.







Thank you,

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use a Data Set list or the colon shortcut:

*Combines dsn1 to dsn_5;

data final;

set dsn_1-dsn_5;

run;

or

*Combines anything that starts with DSN

data final;

set dsn:;

run;

View solution in original post

2 REPLIES 2
Reeza
Super User

Use a Data Set list or the colon shortcut:

*Combines dsn1 to dsn_5;

data final;

set dsn_1-dsn_5;

run;

or

*Combines anything that starts with DSN

data final;

set dsn:;

run;

Astounding
PROC Star

If you save the combined file, it's quick and easy:

proc append base=combined_file data=new_file;

run;

This program requires that the variable definitions are identical.

Good luck.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 926 views
  • 1 like
  • 3 in conversation