Currently I am using:
ODS CSV FILE="DISP_PRE1882.csv" TYPE=csvall PATH="/home/xxxx";
PROC PRINT DATA=COMBINED3;
RUN;
ODS CSV close;
wondering if there is a faster way to do this? The Dataset has amost 1 million rows and it can take a while...
Thanks!!
-Geoff
Proc export data=combined
outfile="DISP_PRE1882.csv" /* second = character removed*/
dbms=CSV
replace
;
run;
If you want the variable labels instead of the names add LABEL before the ; on the proc statement.
I do recommend always using a fully qualified path instead of just the out file name as the folder it ends up in may be problematic for some uses.
Proc export data=combined
outfile="DISP_PRE1882.csv" /* second = character removed*/
dbms=CSV
replace
;
run;
If you want the variable labels instead of the names add LABEL before the ; on the proc statement.
I do recommend always using a fully qualified path instead of just the out file name as the folder it ends up in may be problematic for some uses.
Ok, so I add the full path in the outfile?
and why is there 2 ==?
@StaticFX its a typo, a single = is fine.
Good lord its like night and day! this took 11.9 seconds to write 1.02m records to the file! Plus it was 27mb smaller... Thanks so much!
I havent tried the others to compare, but no need now lol
You also might try writing directly to a compressed file and see if that makes it faster. The computer will probably spend more CPU cycles compressing the file, but much less time will be spend waiting for the data to be written to the disk.
You could use the ZIP filename engine. And if you have at least SAS 9.4 M5 release you can use GZIP format which should be a little faster as it does not have the overhead of multiple file archives like ZIP format.
%let path=%sysfunc(pathname(work));
filename csv "&path/class.txt";
proc export data=sashelp.class file=csv dbms=csv ; run;
filename csvgz zip "&path/class.txt.gz" gzip ;
proc export data=sashelp.class file=csvgz dbms=csv ; run;
filename csvzip zip "&path/class.zip" member='class.txt' ;
proc export data=sashelp.class file=csvzip dbms=csv ; run;
Just use a data step.
data _null_ ;
file "/home/xxxx/DISP_PRE1882.csv" dsd ;
set COMBINED3;
put (_all_) (+0);
run;
If you need to add a header row you can generate that first and then use the MOD option on the FILE statement in the data step above.
proc transpose data=COMBINED3(obs=0) out=names;
var _all_;
run;
data _null_ ;
file "/home/xxxx/DISP_PRE1882.csv" dsd ;
set names end=eof;
put _name_ @ ;
if eof then put;
run;
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!
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.