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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

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