Split large SAS dataset into smaller datasets

前端 未结 6 483
长情又很酷
长情又很酷 2021-01-13 01:10

I need some assistance with splitting a large SAS dataset into smaller datasets.

Each month I\'ll have a dataset containing a few million records. This number will

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 02:11

    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;    
    

提交回复
热议问题