BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
%macro import(file,dname);	
   Proc import datafile="&file" out=&dname
   Dbms=xlsx replace;
   Getnames=yes;
   Run;
%mend;
%import(/home/u35263349/My_Folder/sheet1.xlsx,ds1);
%import(/home/u35263349/My_Folder/sheet2.xlsx,ds2);
%import(/home/u35263349/My_Folder/sheet3.xlsx,ds3);

proc sql;
create table transaction as
select * from ds1
union all
select * from ds2
union all
select * from ds3;
quit;

data master;
set ds1 ds2 ds3;
run;

Hi Guys i want to import these excel files  dynamically and combine three datasets i tried data step and proc sql  please suggest any alternative method using proc sql

2 REPLIES 2
Patrick
Opal | Level 21

Your SQL code works with your sample Excels. What's the problem/your question.

In case in your real data the columns in the Excels are not always in the same order: Use  union all CORR

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1419 views
  • 0 likes
  • 3 in conversation