BookmarkSubscribeRSS Feed
jerrylshen
Obsidian | Level 7

I'm importing the data from .xlsx and using proc sql to create/manipulate the data in SAS 9.4.

 

This is how I'm currently exporting to .xlsx but this overwrites that particular sheet. I want to reuse the same sheet. 

proc export
DATA = data_name
DBMS = xlsx 
OUTFILE = "C:\\...\outfile.xlsx"
REPLACE;

sheet=sheet_name;
run;

I guess one alternative would be to do all the data manipulation and then do a single export as opposed to data manipulation then export, data manipulation then export, data manipulation then export, and so on. But is there a way to export without overwriting? I tried looking this up and nothing relevant came up.  

Thanks   

   

Edit: I want different sets of data on the same sheet one below the other, sort of like appending

5 REPLIES 5
Reeza
Super User
Not via XLSX afaik. You can with PCFILES though, but then you have some other limitations unfortunately. First you do need to drop that sheet and then re-add it so not sure that will work, if you want other information to remain on the sheet.
ballardw
Super User

Do you want to place to different sets of data on the same sheet one below the other?

Or are you expecting to have this behave as a single block of data just adding lines without a header row?

 

Export in not the most flexible tool as it is pretty much intended to create one output file for one data set.

 

You might be able to accomplish what you want with ODS Excel as that will allow multiple procedures to send ODS output, such as Proc Print, to the same or different sheets depending on options like Sheet_interval.

jerrylshen
Obsidian | Level 7

Alright, thanks for the info, I'll take a look into ODS Excel

Reeza
Super User
ODS EXCEL does assume that you can create an entirely new workbook each time you run this process. It does not have the option of adding sheets to an already existing workbook.
art297
Opal | Level 21

If you're on Windows then take a look at the exportxl macro. I think it can do everything that you described. You can download it from:

http://www.sascommunity.org/wiki/Excelling_to_Another_Level_with_SAS

 

Art, CEO, AnalystFinder.com

 

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
  • 5 replies
  • 2611 views
  • 5 likes
  • 4 in conversation