简体   繁体   English

SAS-进程频率…内存不足?

[英]SAS - proc freq…insufficient memory?

I've rarely used proc freq before. 我以前很少使用proc freq。 I'm trying to run the following and I receive an error says SAS is unable to allocate sufficient memory. 我正在尝试运行以下命令,但收到一条错误消息,提示SAS无法分配足够的内存。 The dataset has about 15,000 records. 数据集约有15,000条记录。 What are my alternatives here? 我在这里有什么选择?

proc freq data=dsb_un noprint; 
table bsn*dsb / out=dsb_un2(where=(count>1) drop=percent); 
run;

Since you're dropping percent, the following should be identical: 由于您要删除百分比,因此以下内容应相同:

proc freq data=dsb_un noprint;
by bsn;
tables dsb/out=dsb_un2(where=(count>1) drop=percent);
run;

The BY statement should decrease the memory allocation significantly. BY语句应显着减少内存分配。 You also could use PROC SQL in a similar way that would probably fit fine in memory. 您也可以类似的方式使用PROC SQL,该方式可能适合内存。

The problem is likely that DSB and BSN are mostly unique values each, so you probably have something like 10k+ values for each - making a master table of 10k*10k or 1e8 cells, requiring 8e8 bytes of memory, which may be beyond your available memory for SAS. 问题可能是DSB和BSN大多都是唯一值,因此您可能每个都有10k +值-制作一个10k * 10k或1e8单元的主表,需要8e8字节的内存,这可能超出了您的可用内存对于SAS。

I've hit this before as well. 我也曾经打过这个。 The way I got around it was simply not to use proc freq . 我绕过它的方法就是根本不使用proc freq I believe I used proc summary instead. 我相信我改用proc summary It can count frequencies just as well. 它也可以计算频率。

First a test dataset: 首先是测试数据集:

data tmp;
  set sashelp.class;
  dummy = 1;
run;

Using your original freq approach: 使用原始的freq方法:

proc freq data=tmp noprint; 
  table sex*age / out=freq1(where=(count>1) drop=percent); 
run;

Using a proc summary approach: 使用proc summary方法:

proc summary data=tmp noprint nway missing;
  class sex age;
  var dummy;
  output out=freq2(where=(dummy>1) drop=_type_ _freq_) sum=;
run;

Note that proc summary may need a dummy variable that you can calculate against. 请注意, proc summary可能需要您可以计算的虚拟变量。 Hence the creation of the dummy=1 flag in my test dataset. 因此,在我的测试数据集中创建了dummy=1标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM