Learning SAS? Welcome to the exclusive online community for all SAS learners.

exporting multiple sas datasets to multiple sheet in one excel workbook

Reply
Contributor
Posts: 25

exporting multiple sas datasets to multiple sheet in one excel workbook

Hi All,

I'm trying to export multiple sas datasets to excel where my multiple sas datasets are multiple sheets in 1 excel file. I wrote a macro for this. I'm sure I made some mistakes as I'm new to macro and still in learning phase. I have about 40 sas datasets. I would really appreciate if you could help me with this.

Thanks,

Esita

libname a "c:\sasdata";

%macro export_data(file=,data=,sheet=);

proc export data=&data.

outfile="&file."

dbms=excel replace;

sheet="&sheet.";

run;

%mend export_data;

%imp (file= "c:\sasdata\blood_result.xls",data= a.rbc,sheet= rbc);

%imp (file= "c:\sasdata\blood_result.xls",data= a.wbc,sheet= wbc);

Valued Guide
Posts: 3,208

Re: exporting multiple sas datasets to multiple sheet in one excel workbook

When you the libname excel access then the libname is a excel file and sheets are the same as tables in SAS.

This is posted in analytics U. Dou you have a desktop version (using cSmiley Happy or the UE running linux in a VM on your desktop?

My human brains as SAS syntax checker does not see any problems with your code.

As it is human it is having a strong error correction mode that code could have still many mistakes.

---->-- ja karman --<-----
Contributor
Posts: 25

Re: exporting multiple sas datasets to multiple sheet in one excel workbook

Thank you, Jaap for you reply. I'm new to this forum as well so I'm not sure where I should have posted. Well, I have a desktop and running windows.

Esita

Ask a Question
Discussion stats
  • 2 replies
  • 399 views
  • 0 likes
  • 2 in conversation