DATA Step, Macro, Functions and more

How to append 180 datasets to one datasets?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 80
Accepted Solution

How to append 180 datasets to one datasets?

Hi team I was able to import 180 datasets to work. same columns each file has 35k records they are all title with date it was produced. . For example
D160101. D160102. D160103. D160104 ...
I have hundreds datasets how can I create a macro to append all of them ? Thanks

Accepted Solutions
Solution
‎07-30-2016 08:13 PM
Super User
Posts: 17,899

Re: How to append 180 datasets to one datasets?

They all start with D? Do you have other datasets in the library that you need to exclude?

 

You can do it without a macro, using the colon short cut. This will append all datasets that start with the letter D.

 

data want;
set D:;
run;

If you need a macro and want to use proc append, I would use the following method:

 

1. Write macro to use PROC APPEND

2. Obtain list of dataset name from sashelp.vtable -> store in a dataset

3. Use call execute to execute macro from #1. 

 

 

View solution in original post


All Replies
Solution
‎07-30-2016 08:13 PM
Super User
Posts: 17,899

Re: How to append 180 datasets to one datasets?

They all start with D? Do you have other datasets in the library that you need to exclude?

 

You can do it without a macro, using the colon short cut. This will append all datasets that start with the letter D.

 

data want;
set D:;
run;

If you need a macro and want to use proc append, I would use the following method:

 

1. Write macro to use PROC APPEND

2. Obtain list of dataset name from sashelp.vtable -> store in a dataset

3. Use call execute to execute macro from #1. 

 

 

Frequent Contributor
Posts: 80

Re: How to append 180 datasets to one datasets?

Thanks Reeza that worked
Super User
Posts: 17,899

Re: How to append 180 datasets to one datasets?

Why did you mark your answer as correct?

Frequent Contributor
Posts: 80

Re: How to append 180 datasets to one datasets?

Reeza. data want; set D:; run; this appended all the files that start with D it's what I was looking for
SAS Super FREQ
Posts: 8,743

Re: How to append 180 datasets to one datasets?

But it was Reeza's answer that was correct. You marked your response as correct, not her answer.
cynthia
Frequent Contributor
Posts: 80

Re: How to append 180 datasets to one datasets?

Oops I didn't see that's what I did my error
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 564 views
  • 2 likes
  • 3 in conversation