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

查看:27
本文介绍了划分 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 拆分为 10 个名为 NEWDATA1 - NEWDATA10 的数据集的示例调用如下:

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天全站免登陆