Hi,
I am trying to create one excel file with different sheets for each dataset by using proc export. Following is my macro:
%macro export;
libname output "XXXXX";
%let domains=AE#DM;
%do i = 1 %to %eval(%sysfunc(count(&domains,#))+1);
%let dsn=%scan(&domains,&i,#);
proc export data=&dsn label
dbms=xlsx
outfile="test.xlsx"
replace;
;
sheet="&dsn.out" ;
run;
libname output;
%end;
%mend;
options merror serror symbolgen mlogic;
%export;
This macro overrides the existing sheet of AE.
Please let me know how to not override the previous sheet or append these sheets.
Thank you.
Use "options mprint symbolgen;" as well as some %put statements to check the values of those parameters and see what is happening in each iteration of hte loop. It looks to me like the sheet names it would write out would be AEout.
You can add the SHEET= along with the REPLACE option to your PROC EXPORT step.
I already have SHEET= option in macro
libname x xlsx 'c:\temp\want.xlsx' ;
or
libname x excel 'c:\temp\want.xlsx';
proc copy in=work out=x;
select ae stdm;
run;
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.