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.
thank you.
I don't have anything to attach as I am looking for the example I had previously.
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:
http://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/
By amount
https://communities.sas.com/t5/Base-SAS-Programming/split-file-into-multiple-files/td-p/56457
If your final output is a text file use file options, see example 4&5 here
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.
If your doing a data transfer then best to use an appropriate format, CSV, XML, etc.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.