11-16-2016 09:55 PM
Hello, I found a real good macro here once that split a huge dataset (500K) records into equal portions of 30,000 and it was so simple, but now I can't find it. I would like to split a file only 34K records by account number into equal records of 500 records. I know I know its about 64 datasets, however that is all the other end can handle.
I don't have anything to attach as I am looking for the example I had previously.
11-17-2016 12:03 AM
Splitting files is relatively trivial if you have clear rules.
You say account number and 500 records? Does that mean each file is for a single account and maximum 500 records? Or can a file of 500 records have multiple accounts?
What is the final output format, Excel, csv, sas7bdat data set?
Split it by grouping variable:
If your final output is a text file use file options, see example 4&5 here
11-17-2016 06:07 AM
To be honest, unless there is a clear reason (maybe file transmittal can only old a certain amount) then its not a good idea to split data. It just means you end up with lots of segments to program on.
Its is trvial however to do:
data _null_; set your_data nobs=n; do i=1 to (n/500); call execute('data temp; set your_data point='||put(i-1*500)||' obs=500; run;'); call execute('proc export data=temp outfile="<path to file>\File'||strip(put(i,best.))||'.xls"; run;'); end; run;
Do note, not tested, but something like that should work.