In this tutorial we shall learn about how to export data from SAS using PROC EXPORT.
We will mainly focus on importing:
For this tutorial we are using SAS' inbuilt dataset SASHELP.SHOES for exporting.
Exporting a CSV file
PROC EXPORT DATA = SASHELP.SHOES
OUTFILE = '/home/u50132927/My_datasets/My_exported_csv.csv'
DBMS = csv REPLACE;
RUN;
Using the above syntax we can export our CSV file from SAS. Following is the explanation of keywords in PROC EXPORT.
DATA : Library and file name which needs to be exported.
OUTFILE : Location and filename of the new file which will be saved.
DBMS = CSV (for CSV files)
REPLACE: Replace the already existing dataset. In our case if My_exported_csv.csv exists then that will be replaced by our new file.
Exporting an excel file
PROC EXPORT DATA = SASHELP.SHOES
OUTFILE = '/home/u50132927/My_datasets/My_exported_xlsx.xlsx'
DBMS = XLSX REPLACE;
RUN;
For exporting excel file we mention DBMS = XLSX or XLS (depending which version of MS-Office you are using)
We can also export various datasets in a single excel (each data in a single sheet) in SAS. To know more you can refer to this tutorial.
Exporting a TXT file
PROC EXPORT DATA = SASHELP.SHOES
OUTFILE = '/home/u50132927/My_datasets/My_exported_txt.txt'
DBMS = TAB REPLACE;
RUN;
For exporting a txt file we mention DBMS = TAB.
Comments