BookmarkSubscribeRSS Feed
jmmedina252
Calcite | Level 5

Hello, I'm trying to export data from a SAS table to different sheets based on a variable's values (variable=site).  I also need to sort by a few variables (date and type) before export, which is the reason I cannot use the code below.

 


ods excel file="\\filepath\file.xlsx"
options(sheet_interval="BYGROUP");


proc print data=doc noobs;
by site ;
run;
ods excel close;

2 REPLIES 2
ballardw
Super User

@jmmedina252 wrote:

Hello, I'm trying to export data from a SAS table to different sheets based on a variable's values (variable=site).  I also need to sort by a few variables (date and type) before export, which is the reason I cannot use the code below.

 


ods excel file="\\filepath\file.xlsx"
options(sheet_interval="BYGROUP");


proc print data=doc noobs;
by site ;
run;
ods excel close;


What exactly makes you think that you can't use this?? If you Sort the data by SITE DATE and TYPE then the result of Print by Site is one sheet per site with the data in Date and Type order.

 

You are not successfully describing what your output requirement might be.

Oligolas
Barite | Level 11

Hi,

Excel sheets can be created like this:

Proc Export data=sashelp.class
   outfile="C:\Temp\yourFile.xlsx"
   dbms=EXCEL
   Replace;
  sheet='Class';
run;

Simply repeat the operation for several sheets

________________________

- Cheers -

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 550 views
  • 0 likes
  • 3 in conversation