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

Hello SAS experts,

 

I have a list of datasets with the same name and variables structure, and I want to add them all in a single one.

this doesn't work:

data vzk_2020;

do i=1 to 8;

set vzk_2020_i;

end;

run;

what's the correct way?

 

regards,

PY

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

This is where you need a macro. You need one SET statement, but multiple datasets in it.

%macro dsnames;
%do i = 1 %to 8;
  vzk_2020_&i.
%end;
%mend;

data vzk_2020;
set
  %dsnames
;
run;

Take note where I placed semicolons, and where I omitted them.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

This is where you need a macro. You need one SET statement, but multiple datasets in it.

%macro dsnames;
%do i = 1 %to 8;
  vzk_2020_&i.
%end;
%mend;

data vzk_2020;
set
  %dsnames
;
run;

Take note where I placed semicolons, and where I omitted them.

PierreYvesILY
Pyrite | Level 9
thank you Kurt, have a nice day!
Ksharp
Super User
data vzk_2020;
set vzk_2020_1 - vzk_2020_8 ;
run;

OR Just:
data vzk_2020;
set vzk_2020_: ;
run;