*
; /* Subject: Re: SAS/EXCEL From: "Bruce Bradbury (remove deletethis from address)";Date: 1998/01/15 Newsgroups: comp.soft-sys.sas >Is there anyon who cal help me with how use the put statment to put som >lines of text into excel's sheet? You might find this macro of use. */ %macro toexcel(infile=_last_,ws=sheet1); %*--------------------------------------------------------- Takes a sas file INFILE and outputs it to the top-left corner of an excel worksheet WS. Assumes that excel is running with the worksheet open. ---------------------------------------------------------; * first put numbers of variables and cases into macro variables; data _null_; set &infile (obs=1) nobs=cases; array all{*} _all_; call symput('ncases',cases); call symput('nvars',trim(left(dim(all)))); * write variable names to temporary file; file temptox; do i=1 to dim(all); put all(i)=; end; file log; run; * put variable names into macro variables; data _null_; infile temptox delimiter='='; input name $ value $; vnum=left(trim('v')||trim(left(_n_))); call symput(vnum,trim(name)); run; * setup link to excel worksheet to put out names; filename tox1 dde "excel|&ws!r1c1:r1c&nvars" notab lrecl=10000 ; * put names to worksheet; data _null_; file tox1 ; put %do i=1 %to &nvars; "&&v&i" '09'x %end; ; run; * link to output values; filename tox2 dde "excel|&ws!r2c1:r%eval(&ncases+1)c&nvars" lrecl=10000; data _null_; set &infile; file tox2; put %do i=1 %to &nvars; &&v&i %end; ; run; %mend toexcel; *