0

尽管我只有 3200 条记录,但此代码生成的文件大小大于 5MB。有什么建议么 ?帮助将不胜感激。从过去的两天开始,我一直在努力解决它。

它给了我内存不足的错误。我还有其他与这个非常相似的代码,我能够运行该代码而不会出现任何错误。

%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;

提前致谢。

4

1 回答 1

1

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

检查导出到 excel 的所有变量的宽度。它们很宽。结合起来,它们的宽度约为 2500 字节。

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

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

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

于 2015-05-14T20:55:14.150 回答