The SAS Output Delivery System and reporting techniques

PROC SQL Export to Excel

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 141
Accepted Solution

PROC SQL Export to Excel

Is there a way when using proc sql statements in PC SAS to export directly to excel?  I'd like to be able to write queries in PC SAS to do this as easily as I can do a "Send To Excel" in Enterprise Guide.

 

Thanks!


Accepted Solutions
Solution
‎07-15-2016 10:21 AM
Super User
Super User
Posts: 7,686

Re: PROC SQL Export to Excel

Simple answer, no.  SQL is a query language, it is used for querying data, not for creating proprietary file formats. Simplest method is to proc export the resulting dataset, though I can't see your full process here, so unable to see where best it would fit in. 

View solution in original post


All Replies
Solution
‎07-15-2016 10:21 AM
Super User
Super User
Posts: 7,686

Re: PROC SQL Export to Excel

Simple answer, no.  SQL is a query language, it is used for querying data, not for creating proprietary file formats. Simplest method is to proc export the resulting dataset, though I can't see your full process here, so unable to see where best it would fit in. 

Frequent Contributor
Posts: 141

Re: PROC SQL Export to Excel

Thanks @RW9. I am simply running a proc sql query and creating a temp table. I will run a proc export but I was just curious if that could be included in a proc sql statement itself or not.
Super User
Posts: 19,038

Re: PROC SQL Export to Excel

In PC SAS you can right click on a dataset and view in Excel. 

 

If you have 9.4 then you can use ODS EXCEL. 

 

Ods excel file='path';

 

proc sql...

 

 

ods excel close;

 

At the end of the day, I agree with @RW9 and you should use proc export. It's easier to manage outputs in long run IMO. 

Frequent Contributor
Posts: 141

Re: PROC SQL Export to Excel

I do have 9.4 and this is a useful tool.  I wasn't aware of this.  I can see the benefit of both options however.  I like @Reeza's method for the quick and dirty ad hoc query but could see a lot of automation being done easier with @RW9's suggestion using proc export.

 

Thank you both for the help!

Super User
Posts: 9,856

Re: PROC SQL Export to Excel

Try LIBNAME which is my favorite .




libname xx xlsx '/folders/myfolders/want.xlsx';
proc sql;
create table xx.class as
 select * from sashelp.class;
quit;



☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 2355 views
  • 5 likes
  • 4 in conversation