|
You could use a macro but you don't have to. The alternative is to write everything to the same range and use "System" commands to repeatedly SaveAs.
Here is some typical code (fragmentary). EXCELSIC is a SAS data set and PATH is a SAS macrovariable.
filename outdata dde 'excel|sheet1!r1c1:r300c7';
filename commands dde 'excel|system';
data _null_;
set excelsic; by sic;
file outdata notab;
if first.sic then do;
[some PUT statements]
end;
[more PUT statements]
;
if last.sic then do;
[more PUT statements]
* Output buffer flush necessary to fill spreadsheet before saving to disk;
put '!DDE_FLUSH';
file commands;
length excelcmd $ 200;
excelcmd = '[SAVE.AS("' || "&PATH\sic\" ||
substr(sic,1,2) || '.xls",1,"",FALSE,"",FALSE)]';
put excelcmd;
end;
run;
As explained in a very recent thread, the Excel v. 4 macro language, not VBA, is the supported command set.
In my paper "Getting Started with Dynamic Data Exchange" (http://www.ita.doc.gov/industry/otea/dcsug/ddepaper.pdf) I have an example of generating multiple worksheets.
-----Original Message-----
Date: Mon, 24 Jan 2000 21:56:27 GMT
From: stephno1@MY-DEJA.COM
Subject: Help with macros, excel 97 and SAS 6.12
The situation is this..
I have a dataset with about 50 subjects each with an id number. For
each subject there are from 1 to several observations. I have a SAS
program to do some computations on the observations. Now I need to
write a macro that will...
take each subject, put their specific info into excel on their very own
worksheet and label the tabs by the id number
I am writing an Excel macro to take the information and make some nice
graphs per each worksheet.
I know how to tell SAS to output things to excel...
filename out dde
'Excel|[filename.xls]worksheet!beginning cell:ending cell';
data dataset;
set dt.dataset;
file out notab;
run;
I would appreciate any help.
Sent via Deja.com http://www.deja.com/
Before you buy.
|