分区sas数据集以进行批处理的最快方法是什么? [英] What's the fastest way to partition a sas dataset for batch processing?

查看:149
本文介绍了分区sas数据集以进行批处理的最快方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大型的sas数据集(1.5m obs,约250个变量),我需要将其拆分为大小相同的几个较小的sas数据集以进行批处理.每个数据集都需要包含所有变量,但仅包含obs的一小部分.最快的方法是什么?

I have a large sas dataset (1.5m obs, ~250 variables) that I need to split into several smaller sas datasets of equal size for batch processing. Each dataset needs to contain all the variables but only a fraction of the obs. What is the fastest way of doing this?

推荐答案

您可以执行以下操作:

%macro splitds(inlib=,inds=,splitnum=,outid=);

  proc sql noprint;
    select nobs into :nobs
    from sashelp.vtable
    where libname=upcase("&inlib") and memname=upcase("&inds");
  quit;
  %put Number of observations in &inlib..&inds.: &nobs;

  data %do i=1 %to &splitnum.;
         &outid.&i
       %end;;
    set &inds.;
    %do j=1 %to (&splitnum.-1);
      %if &j.=1 %then %do;
        if
      %end;
      %else %do;
        else if
      %end;
                _n_<=((&nobs./&splitnum.)*&j.) then output &outid.&j.;
    %end;
    else output &outid.&splitnum.;
  run;
%mend;

将MYLIB.MYDATA拆分为名为NEWDATA1-NEWDATA10的10个数据集的示例调用为:

An example call to split MYLIB.MYDATA into 10 data sets named NEWDATA1 - NEWDATA10 would be:

%splitds(inlib=mylib,inds=mydata,splitnum=10,outid=newdata);

这篇关于分区sas数据集以进行批处理的最快方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆