Proc DBLOAD - Send SAS Data to Excel
Monday, March 31, 2008
Jared in SAS

I came across this sample on the SAS Support website.

I constantly get people in my organization who require data. Usually it’s a simple table with a few columns. Since the Microsoft Office Suite is installed on our computers and is supported software, I opt for giving them Excel spreadsheets. That way they can play with the data themselves. Here is a nice chunk of code to send your SAS Data to an Excel file:

/* This program writes a SAS Data Set to EXCEL using DBLOAD */

proc dbload dbms=xls data=sasuser.houses;
path=’c:\path\to\my\folder\filename.xls’;
putnames=yes;
label;
reset all;
limit=0;
load;
run;

Using my my test dataset, Class, we can see the code works quite nicely.

%let filename = ‘c:\class.xls’;

proc dbload dbms=xls data=class;
path=&filename;
putnames=yes;
label;
reset all;
limit=0;
load;
run;

/*open the excel file*/
options nowait;
X &filename;
*systask command “&filename”;/*try this if the X command doesn’t work*/

Keep your computer clean - don’t forget to delete c:\class.xls afterwards.

 

Article originally appeared on jaredprins (http://jaredprins.squarespace.com/).
See website for complete article licensing information.