将大型SAS数据集拆分为较小的数据集
在将大型SAS数据集拆分为较小的数据集时,我需要一些帮助.
I need some assistance with splitting a large SAS dataset into smaller datasets.
每个月我都会有一个包含数百万条记录的数据集.这个数字每个月都会有所不同.我需要将此数据集拆分为多个较小的数据集,每个数据集包含250,000条记录.例如,如果我在原始数据集具有1,050,000记录然后我需要的最终结果是含有250000个记录和含有50000个记录数据集1数据集4
Each month I'll have a dataset containing a few million records. This number will vary from month to month. I need to split this dataset into multiple smaller datasets containing 250,000 records each. For example, if I have 1,050,000 records in the original dataset then I need the end result to be 4 datasets containing 250,000 records and 1 dataset containing 50,000 records.
从我一直在看的东西看来,这将需要使用宏.不幸的是,我是SAS的新手(不熟悉使用宏),并且没有太多时间来完成此操作.任何帮助将不胜感激.
From what I've been looking at it appears this will require using macros. Unfortunately I'm fairly new to SAS (unfamiliar with using macros) and don't have a lot of time to accomplish this. Any help would be greatly appreciated.
建立在乔的回答,也许你可以尝试这样的事:
Building on Joe's answer, maybe you could try something like this :
%MACRO SPLIT(DATASET);
%LET DATASET_ID = %SYSFUNC(OPEN(&DATASET.));
%LET NOBS = %SYSFUNC(ATTRN(&DATASET__ID., NLOBS));
%LET NB_DATASETS = %SYSEVALF(&NOBS. / 250000, CEIL);
DATA
%DO I=1 %TO &NB_DATASETS.;
WANT&I.
%END;;
SET WANT;
%DO I=1 %TO &NB_DATASETS.;
%IF &I. > 1 %THEN %DO; ELSE %END; IF _N_ LE 2.5E5 * &I. THEN OUTPUT WANT&I.;
%END;
RUN;
%MEND SPLIT;