Proc报告导出的文件大小超出预期

时间:2015-05-14 18:12:40

标签: sas proc-report

此代码生成的文件大小超过5MB,即使我只有3200条记录。有什么建议 ?帮助将不胜感激。过去两天我一直在努力。

它给了我足够的内存错误。我有其他代码与此非常相似,我可以运行该代码而没有任何错误。

%macro report(date);

%let a= %eval(%sysfunc(today());
%let Year= %sysfunc(putn(&a,year4.));
%let Mon= %sysfunc(putn(&a,month2.));
%let Day= %sysfunc(putn(&a,day2.));


Proc SQL;

Create table vdata.Report as
Select Country, Province, City, Code, Link, Activity, First_Name, Last_Name, 
Is_Coordinator, Is_Host, email, Phone, Business_Group, Managers_Email, Transportation
from V_Data.raw_plus_&date;

Quit;


Proc Sort data=vdata.PM_Report;
by Country Province Activity Last_Name;
run;


ods listing close;
ods tagsets.EXCELXP file="/path/ Report - &date..XML";
ods tagsets.ExcelXP options (Sheet_name="Report");

proc report data=vdata.Report nowd 
style(header)=[font_weight=bold background=cxDCE6F1 font_size=1.2 ]
;
COLUMN ("Registration as of &Year-&Mon-&Day" ("Report" Country Province City Code Link Activity First_Name Last_Name 
Is_Coordinator Is_Host email Phone Business_Group Managers_Email  Transportation));

DEFINE  Country / Display FORMAT= $char100. Style(column)=[WIDTH=75 font_size=1] style(header)=[background = CXC2D69A]   SPACING=2   LEFT "Country" ;
DEFINE  Province / Display FORMAT= $char100. Style(column)=[WIDTH=60 font_size=1] style(header)=[background = CXC2D69A]  SPACING=2   LEFT "Province";
DEFINE  City / Display FORMAT= $char100. Style(column)=[WIDTH=80 font_size=1]  style(header)=[background = CXC2D69A]   SPACING=2   LEFT "City" ;
DEFINE  Code / Display FORMAT= $char100. Style(column)=[WIDTH=170 font_size=1]  style(header)=[background = CXC2D69A]  SPACING=2   Left "Project ID#" ;
DEFINE  Link / Display FORMAT= $char100. Style(column)=[WIDTH=200 font_size=1] style(header)=[background = CXC2D69A]    SPACING=2   left "Region" ;
DEFINE  Activity / Display FORMAT= $char100. Style(column)=[WIDTH=500 font_size=1]  style(header)=[background = CXC2D69A]  SPACING=2   left "Select an Activity" ;
DEFINE  First_Name / Display FORMAT= $char100. Style(column)=[WIDTH=90 font_size=1]  style(header)=[background = CXC2D69A]  SPACING=2   left "First Name" ;
DEFINE  Last_Name / Display FORMAT= $char100. Style(column)=[WIDTH=220 font_size=1] style(header)=[background = CXC2D69A]   SPACING=2   left "Last Name" ;
DEFINE  Is_Coordinator / Display FORMAT= $char100. Style(column)=[WIDTH=120 font_size=1] style(header)=[background = CXC2D69A]   SPACING=2   left "Activity Coordinator" ;
DEFINE  Is_Host / Display FORMAT= $char100. Style(column)=[WIDTH=80 font_size=1]  style(header)=[background = CXC2D69A]  SPACING=2   left "Host" ;
DEFINE  Email / Display FORMAT= $char100. Style(column)=[WIDTH=250 font_size=1]  style(header)=[background = CXC2D69A]  SPACING=2   left "e-mail" ;
DEFINE  Phone / Display FORMAT= $char100. Style(column)=[WIDTH=100 font_size=1]  style(header)=[background = CXC2D69A]  SPACING=2   left "phone #" ;
DEFINE  Business_Group / Display FORMAT= $char100. Style(column)=[WIDTH=270 font_size=1]  style(header)=[background = CXC2D69A]  SPACING=2   left "Business Group" ;
DEFINE  Managers_Email / Display FORMAT= $char100. Style(column)=[WIDTH=220 font_size=1]  style(header)=[background = CXC2D69A]  SPACING=2   left "Reporting Managers Email" ;
DEFINE  Transportation / Display FORMAT= $char100. Style(column)=[WIDTH=220 font_size=1] style(header)=[background = CXC2D69A]   SPACING=2   left "Transportaion needed?" ;

Compute country;
if country = "Canada" then 
    call define(_row_, 'style', 'style = {background=#FFFFFF FONT_SIZE=1}' );
else if country = "United States" then
    call define(_row_, 'style', 'style = {background=#FFFFFF FONT_SIZE=1}' );
endcomp;


RUN;


ODS ods tagsets.ExcelXP CLOSE;

%Mend;

提前致谢。

1 个答案:

答案 0 :(得分:1)

我没有对此进行测试,但我猜测它与您导出的字段的宽度有关。

检查导出到excel的所有变量的宽度。它们非常广泛。它们的组合宽度约为2500字节。

Width*Rows = ~2500*3200 = 8,000,000 bytes = 8 megabytes

我不确定excel是否对连续的空格字符进行任何压缩,但如果没有,那么这很容易解释大小。

对于任何过宽的变量,请使用length语句为它们指定适当的宽度。我很确定你的电话号码宽度不需要100(例如)。