*
;
/*
From: "Mark" 
Newsgroups: comp.soft-sys.sas
Subject: Re: exporting sas win 6.11 to excel
Date: 10 Feb 1997 13:11:54 GMT
Organization: Cable Internet

Lars Ladfors  wrote in article
<32FEF683.7060@kk.ostra.se>...
> I have a datset called dok.k1234 with 285 variables, 
> I would like to export all data to excel. How to do that?
> I use, PC windows, SAS 6.11.
> 
> Lars
> 

to call in SAS: %excel (dok.k1234) ; 

*/


%macro excel (data) ;
proc contents data=&data out=work.contents short noprint ;
run ;

data _null_ ;
set work.contents end=last ;
call symput ('var'!!trim(left(put(_n_,8.))),name) ;
if last then do ;
  call symput ('no_vars',trim(left(put(_n_,8.)))) ;
  call symput ('no_obs',trim(left(put(nobs,8.)))) ;
end ;
run ;

filename exceldmp dde "excel | Sheet1 ! r1c1:r&no_obs.c&no_vars" notab ;
data _null_ ;
file exceldmp ;
set &data ;
put
%do loop=1 %to &no_vars ;
  &&var&loop '09'x
%end ;
;
run ;
filename exceldmp clear ;

%mend excel ;

*
;