BookmarkSubscribeRSS Feed
Fluorite | Level 6

Hi Team,


I use the below code to export a dataset into an xlsx file which is 24Mb in size.

proc export data= work.mydata
Outfile = "/location/file.xlsx" dbms = xlsx replace;


I want to reduce the size of the file as this file is anticipated to grow in size.

I tried generating a .csv file in many ways but they all increased the file size to 55 Mb!


CSV code1 used:

/****file size 55Mb******/

filename _dataout zip "/location/" member="file.csv";

proc export data=work.mydata
dbms=csv replace;

/* although the zip file compressed the file but when tried to save the .csv on the desktop it retained the original csv size of 55Mb*/


csv code2 used:

proc export data=work.mydata
outfile="location/file.csv" dbms = csv replace;

/****file size 55Mb******/


Csv code3 used:

data _null_;
set work.mydata;
file '/location/file.csv' dlm=',' dsd ;
put (_all_) (:) ;

/****file size 55Mb******/


can anyone please help me reduce the file size.

Pyrite | Level 9

Couple of things that might work:

1. Cutting down the CHAR variable lengths.

2. Remove compression from the SAS dataset if compressed. Use PROC CONTENTS to check.

Jade | Level 19

xlsx-files will be smaller than csv-files most times, because a xslx-file is just a zipped collection of xml-files. On a windows system, i would recommend using file-system-compression, but i don't know if a similar feature is available in your environment. Why do you have to export the file at all? Why not saving the dataset in a permanent library?

Fluorite | Level 6

Thank you for the information..

The file has to be sent through email and the team needs it in one of the excel formats..

Super User

As noted, Excel files are already ZIP-compressed, and you could only make your file smaller by reducing the data as such. And I don't mean to get rid of blanks (these are eliminated by the compression anyway), you have to reduce information.


Instead of sending around emails, use a shared storage resource and send links to that.

We simply store such data on our SAS server, and have users use SFTP clients to download it.


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


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
  • 4 replies
  • 4 in conversation