Dynamic first observation: Need to put a variable in firstobs=

前端 未结 1 1476
北海茫月
北海茫月 2021-01-25 19:46

I couldn\'t find anything on google.

I have a data set and need to iterate it in chunks, first chunk would be: firstobs = 1 obs = 30000 second chunk would be: firstobs =

相关标签:
1条回答
  • 2021-01-25 20:19

    Write a macro to do what you want.

    %macro loop(max,by);
    %do i=%eval(1+&by) %to &max %by &by;
    
    data _null_;
    set all_include_Stornos(firstobs=%eval(&i-&by) obs=&i);
    ...
    run;
    %end;
    %mend;
    %loop(90001,30000)
    

    Edit: Realized I should explain how fisrtobs= and obs= work. Basically, it starts at record "firstobs" and ends at "obs". So you use a macro loop to go from 1 to 90001 by 30000. This way you only process 30k records at a time. You can always change the "by" value in the macro if you need to reduce the chunk size.

    0 讨论(0)
提交回复
热议问题