macroHello
I have written a SAS macro to open an excel spreadsheet using dde. I've also got one to do a "save as"
%macro excelsaveas(ifile, ilength);
filename cmds dde 'excel|system';
data _null_;
file cmds;
put '[error(false)]'; *prevent excel asking "are you sure?";
put &ifile;
x=sleep(&ilength.);
put "[QUIT()]";
x=sleep(&ilength.);
run;
%mend;
I can call the macro like this
%excelsaveas(%str('[SAVE.AS("C:\TEMP\test2.xls")]'), 5);
The first parameter is the save-as name and location. The second parameter is how many seconds SAS should sleep for before continuing, because SAS doesn't know when the execution of the save-as command has been completed.
This works fine, however what I want to do is include a macro variable in the save-as name of the spreadsheet. This will allow me to save the spreadsheet with the date in the name, which would be really useful! However, I can't find any combination of double/single quotes or quoting functions that work. I've also tried rewriting the macro in various ways, but SAS always comes back with an error.
Has anyone done something like this before, is it possible, and if so how?
Many thanks