BookmarkSubscribeRSS Feed
mmea
Quartz | Level 8

Hi

I have data with over 4 millions observations

How can I export these data to multiple sas7bdat files with 1 million observation in each file?

 

 

2 REPLIES 2
Kurt_Bremser
Super User

The question is: what for?

4 million observations ain't really much, so you're better off processing them at once.

 

Nevertheless, here's a little example:

%macro splits(inlib=,inds=,outlib=,outds=,split=);

%local num_ds i;

proc sql noprint;
select ceil(nobs/&split) into :num_ds from dictionary.tables
where libname = "&inlib." and memname = "&inds.";
quit;

data
%do i = 1 %to &num_ds.;
  &outlib..&outds.&i.
%end;
;
set &inlib..&inds.;
select (ceil(_n_/&split.));
%do i = 1 %to &num_ds.;
  when (&i) output &outlib..&outds.&i.;
%end;
end;
run;

%mend;

%splits(inlib=SASHELP,inds=CARS,outlib=WORK,outds=C,split=100)
Ksharp
Super User
The simplest code is:

data a b c d;
set have;
if _n_<=1000000 then output a;
else if _n_<=2000000 then output b;
else if _n_<=3000000 then output c;
else output d;
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 709 views
  • 1 like
  • 3 in conversation