Hello!
I'm attempting to do an inner join on multiple tables. This code is within a %DO loop with n as the variable.
%let file1=datahave1;
%let file2=datahave2;
.
.
.
%let file10=datahave10;
%let numoffiles=10;
libname input "path";
%macro formatex;
%do n=1 %to &numoffiles;
proc sql;
create table name1&&file&n as
select *
from name2&&file&n a inner join input.&&file&n.._base b
on a.ssn = b.&pat_ssn and a.record_id= b.record_id
quit;
run;
%end;
%mend;
%formatex;
Right now it just runs the SQL step forever. I'm new to macros, so any help would be greatly appreciated!
When writing a single statement that spans multiple lines put the semi-colon that ends it on its own line. Like the END in a DO/END block.
Then you are less likely to forget it or insert extra ones.
create table name1&&file&n as
select *
from name2&&file&n a
inner join input.&&file&n.._base b
on a.ssn = b.&pat_ssn
and a.record_id= b.record_id
;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.