Published on :
Macro MIXTE

CSV Export Macro (ex_csv)

This code is also available in: Deutsch Español Français
This macro encapsulates the `PROC EXPORT` procedure to facilitate the creation of CSV files from SAS© tables. It accepts the source table, destination path, as well as options for file replacement and inclusion of column headers as parameters.
Data Analysis

Type : MIXTE


The macro expects a SAS table as input, specified by the `dsn` parameter during the call.

1 Code Block
PROC EXPORT
Explanation :
Definition of the `%ex_csv` macro. It executes a `PROC EXPORT` with `dbms=csv` to generate the specified output file.
Copied!
1%macro ex_csv(
2/* positional parameters */
3/* <libref>.SAS-data-set */ dsn
4,/* filepath */ filepath
5 
6/* key-word parameters */
7,/*(blank)|REPLACE */ replace=replace
8,/* YES | NO*/ putnames=yes
9);
10 
11 PROC EXPORT DATA=&dsn
12 outfile="&filepath"
13 dbms=csv &replace;
14 putnames=&putnames;
15 RUN;
16%mend ex_csv;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.