02-25-2014 05:24 AM
Hello, I have a set of datasets which I would like to output in an Excel File. Is there a way to do this quickly rather than calling proc export each time for each dataset
%let MyDS = ('out.Ids', 'out.Vars', 'out.Places')
%let MyDSname = (Ids, Vars, Places)
I would like to create a macro that check if each dataset exists and then output to an Excel spreadsheet with the Tab name as specified in the corresponding MyDSname ...
Something like... %macro Out(MySpreadsheetName, MyDS, MyDSname);
Thanks very much for your help
02-25-2014 07:17 AM
Or the exist function to check the the existence.
If you use the open(), as suggested by LinusH, it's better to use the close after the check, otherwise the DataSet could be locked.
02-25-2014 12:01 PM
Thanks Linus, but the macro variable MyDS refers to the list of datasets 3 in this case. The macro variable MyDSname corresponds to the name I want to call the tab in the spreadsheet which they are store.
I dont think I can just use a proc export directly passing MyDS and MyDSname
I would have to parse MyDS to extract the first value same way MyDSname and then use proc export.
. I wanst sure how to do this.
%let MyDS = ('out.Ids', 'out.Vars', 'out.Places') %let MyDSname = (Ids, Vars, Places)
02-25-2014 01:57 PM
Effective macro coding always starts with the same place: A base SAS section of code that works.
Provide an example of ONE of the proc exports you are attempting that works and then indicate which pieces change.
And you almost never need to include quotes in the parameters as they will be treated by the macro processor as text.