May 27, 2021 SAS
Similar to reading a dataset, SAS can write to a dataset in a different format. I t can write data from an SAS file to a normal text file. T hese files can be read by other software programs. S AS writes to the dataset using PROC EXPORT.
It is an SAS built-in process for exporting SAS datasets to write data to files in different formats.
The basic syntax for writing a procedure in SAS is:
PROC EXPORT DATA=libref.SAS data-set (SAS data-set-options) OUTFILE="filename" DBMS=identifier LABEL(REPLACE);
Here is a description of the parameters used:
We will use the SAS dataset called cars provided in theASHELP library. L et's export it as a text file separated by a space, and the code looks like this.
proc export data=sashelp.cars outfile= '/folders/myfolders/sasuser.v94/TutorialsPoint/car_data.txt' dbms=dlm; delimiter=' '; run;
In the code above we can see the output as a text file and right-click it to see what it is.
In order to write comma-separated files, we can use the dlm option with the value "csv". T he following code is written to car_data.csv.
proc export data=sashelp.cars outfile= '/folders/myfolders/sasuser.v94/TutorialsPoint/car_data.csv' dbms=csv; run;
To execute the above code, we get the output below.
In order to write a tab separator file, we can use the dlm option with the value "tab". T he following code is written to car_tab.txt.
proc export data=sashelp.cars outfile= '/folders/myfolders/sasuser.v94/TutorialsPoint/car_tab.txt' dbms=csv; run;
The data can also be written as HTML files, which we'll see in the Output Delivery System section.