%macro bowling(alley);
proc sql;
%let nwords=%sysfunc(countw(&alley,%str( , )));
create table as (
select * from (
%do j = 1 %to &nwords;
%let alley = scan(j,&alley);
select( *, "&alley" as allnm from
bowling )
%if &j ne &nwords %then %do;
union
%end;
%end;
)
;
quit; In a single query, I am trying to pull information from several datasets in a macro and stack them all on top of each other. The macro will take in a single argument, alley, which will provide a list of bowling alleys. Next, the macro should look up information from a dataset called &alley.sas (ie: if the alley name is Henderson, it's info will be in a dataset called Henderson.sas). I am trying to loop through the list of alleys given, which is what the nwords macro is for, and stack all of that information on each other. When it gets to the alley name in the list, it should end. obviously this macro logic is flawed and there are probably several syntax errors, but this is a rough draft for what I am trying to achieve
... View more