BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
elwayfan446
Barite | Level 11

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!

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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. 

elwayfan446
Barite | Level 11
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.
Reeza
Super User

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. 

elwayfan446
Barite | Level 11

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!

Ksharp
Super User
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;



sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 20684 views
  • 7 likes
  • 4 in conversation