If you want to specify specific sequences of observations here is one way:
data junk1 ; set have(firstobs=1 obs=250 ); run; data junk2 ; set have(firstobs=251 obs=500); run;
but the question does beg for an answer of what gets done with an apparently arbitrary number of records.
With an arbitrary number of records, the best way may be to find the number of records first, e.g.:
data _null_;
call symputx('nobs',nobs);
stop;
set have nobs=nobs;
run;
data want1;
set have(obs=%eval(&nobs/4));
run;
data want2;
set have(firstobs=%eval(&nobs/4+1) obs=%eval(&nobs/2));
run;
data want3;
set have(firstobs=%eval(&nobs/2+1) obs=%eval(3*&nobs/4));
run;
data want4;
set have(firstobs=%eval(3*&nobs/4+1));
run;As shown, it needs a little familiarity with SAS macro language. Which is hard to avoid if you want to do this kind of "advanced" stuff.
Hope this macro program will be helpful.
%MACRO test(lib=,ds=);
proc sql;
select count(*) INTO: nobs
from &lib..&ds. ;
Quit;
%put &nobs;
%do i=0 %to &nobs. %by %SYSFUNC(CEIL(&nobs./4)) ;
data out&i;
set &lib..&ds.(firstobs=%EVAL(&i+1) obs=%EVAL((&nobs./4)+&i) ) ;
run;
%end;
%mend;
%test(lib=sashelp,ds=class);
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.