Hi
i have a sas dataset which has 3 million records but I want to split to 1 million each
can anyone let me know the process and I have to export each 1 million dataset results into a text file ( comma separated )
Use FIRSTOBS = and OBS =
Like: FIRSTOBS = 1 OBS = 1000000
Firstobs = 1000001 OBS = 2000000
Fiirstobs = 2000001 OBS = 3000000
Hi,
Assuming your base data is in work.xyz:
data _null_;
set sashelp.vtable (where=(libname="WORK" and memname="XYZ"));
do I=1 to floor(obs / 1000000) + 1;
call execute('data xyz'||strip(put(I,best.))||'; set work.xyz; if '||strip(put((I-1) * 1000000))||' <= _n_ < '||strip(put(I *1000000))||' then output; run;');
end;
run;
Haven't tested, but something like the above should work.
HI
this also I don't understand but can we use _n_ <=1million then output x
else if _n_. >1million <=2million then output y
can I use something like this
You can, but then you need to manually do each one. I had the loop over 1 to num obs / 1mil so its automatic.
You don't really need to create new data sets if you just want to create CSV files. This is a generic program that will create K CSV files for any input data set. You will need to insure that LRECL if large enough to accommodate the width of your data. And of course depending on you OS you need to adjust the value of &FILE.
Message was edited by: data _null_ It occurred to me that if I was to call this program a generic solution I needed to at least make an effort to guard against variable name clashes with the user's data. I changed the program's "internal" variables to be _variable-name_, which should suffice for most situations.
hi
oh its difficult to understand
You can always RTM.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.