@Tom solution is much more efficient than mine.
This macro splits the files easily for you and then you can export them. You could modify the macro to have it exported as the last step as well.
https://gist.github.com/statgeek/abc3c6ce1dbeedb84fe7f11da0603cda
If you're new to macro programming, I recommend the UCLA tutorials and there's a tutorial on my Github main page which you can find from the Gist page - just walks through the steps to convert a working program to a macro. It's not great but it's there 🙂
Also, you can do this directly within a data step, using the FILEVAR statement which you change the output data file on the fly. This is ultimately Tom's solution.
@nickbarrett wrote:
OK I know how to export a table to csv and I have found BAT way to split the csv into 5000 rows, but it does not keep the header for each file. Just the first file. SO I am looking for a do loop that will export
proc export DATA=clean_table OUTFILE="C:\Table_2019_04_02.csv" DBMS=DLM REPLACE; DELIMITER=','; run;
Depending on the day, the source file could contain between 3000 and 200000 rows of data. I would love to get the files to be exported like
clean_table 14654 rows
Table_2019_04_02-01.csv (5000 rows)
Table_2019_04_02-02.csv (5000 rows)
Table_2019_04_02-03.csv (4654 rows)
Any help would be appreciated! Thanks!
... View more