BookmarkSubscribeRSS Feed
jmmedina252
Fluorite | Level 6

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 -

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 966 views
  • 0 likes
  • 3 in conversation