Reputation: 398
I am creating multiple datasets named "Taxes&i" (&i notes each new dataset according to the counter I. ) The issue I am having is after the loop I am appending the tables.
When I use the code provided from this link, https://support.sas.com/kb/48/810.html I have issues taking my code that I have now and making it flow with this code. I want to use Work instead of abc. as my libname. For my counters I want to use &i and &n instead of the 'count' and instead of name I want to insert taxes.
When I use &i instead of 8. I get an error that says invalid reference and when I change name to taxes I get 18 errors that vary.
%macro loop(list1, list2);
%let n=%sysfunc(countw(&list1, %str('')));
%do i=1 %to &n;
%let O_list1 = %scan(&list1, &i, %str('');
%let O_list2 = %scan(&list2, &i, %str('');
data taxes&i;
food=3*&O_List1;
materials = 4*&O_List2;
%end;
%mend;
run;
%list('1' '2', '3' '4') /*( this is "O_List1", "O_List2") */
Upvotes: 0
Views: 486
Reputation: 21274
I suppose you could do that.
An easier way is to use the shortcut list, since you state they're all labeled TAXES&I.
This will append all datasets from Taxes1 to Taxes18.
data want;
set abc.taxes1-abc.taxes18;
run;
This will append all datasets that start with the word TAXES.
data want;
set abc.taxes: ;
run;
Upvotes: 1