01-22-2015 10:19 AM
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 )
01-22-2015 10:33 AM
Assuming your base data is in work.xyz:
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;');
Haven't tested, but something like the above should work.
01-22-2015 01:15 PM
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
01-22-2015 11:43 AM
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.