- SAS - Dates & Times
- SAS - Macros
- SAS - Input Methods
- SAS - Functions
- SAS - Decision Making
- SAS - Loops
- SAS - Operators
- SAS - Numeric Formats
- SAS - Arrays
- SAS - Strings
- SAS - Variables
- SAS - Data Sets
- SAS - Basic Syntax
- SAS - Program Structure
- SAS - User Interface
- SAS - Environment
- SAS - Overview
- SAS - Home
SAS Data Set Operations
- SAS - Simulations
- SAS - Output Delivery System
- SAS - SQL
- SAS - Format Data Sets
- SAS - Sort Data Sets
- SAS - Subsetting Data Sets
- SAS - Merging Data Sets
- SAS - Concatenate Data Sets
- SAS - Write Data Sets
- SAS - Read Raw Data
SAS Data Representation
SAS Basic Statistical Procedure
- SAS - Hypothesis Testing
- SAS - One-Way Anova
- SAS - Repeated Measure Analysis
- SAS - Fishers Exact Tests
- SAS - Chi-Square
- SAS - Bland-Altman Analysis
- SAS - Linear Regression
- SAS - Correlation Analysis
- SAS - T Tests
- SAS - Cross Tabulations
- SAS - Frequency Distributions
- SAS - Standard Deviation
- SAS - Arithmetic Mean
SAS Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SAS - Write Data Sets
Similar to reading datasets, SAS can write datasets in different formats. It can write data from SAS files to normal text file.These files can be read by other software programs. SAS uses PROC EXPORT to write data sets.
PROC EXPORT
It is a SAS inbuilt procedure used to export the SAS data sets for writing the data into files of different formats.
Syntax
The basic syntax for writing the procedure in SAS is −
PROC EXPORT DATA = pbref.SAS data-set (SAS data-set-options) OUTFILE = "filename" DBMS = identifier LABEL(REPLACE);
Following is the description of the parameters used −
SAS data-set is the data set name which is being exported. SAS can share the data sets from its environment with other apppcations by creating files which can be read by different operating systems. It uses the inbuilt EXPORT function to out the data set files in a variety of formats. In this chapter we will see the writing of SAS data sets using proc export along with the options dlm and dbms.
SAS data-set-options is used to specify a subset of columns to be exported.
filename is the name of the file to which the data is written into.
identifier is used to mention the depmiter that will be written into the file.
LABEL option is used to mention the name of the variables written to the file.
Example
We will use the SAS data set named cars available in the SASHELP pbrary. We export it as a space depmited text file with the code as shown in the following program.
proc export data = sashelp.cars outfile = /folders/myfolders/sasuser.v94/TutorialsPoint/car_data.txt dbms = dlm; depmiter = ; run;
On executing the above code we can see the output as a text file and right cpck on it to see its content as shown below.
Writing a CSV file
In order to write a comma depmited file we can use the dlm option with a value "csv". The following code writes the file car_data.csv.
proc export data = sashelp.cars outfile = /folders/myfolders/sasuser.v94/TutorialsPoint/car_data.csv dbms = csv; run;
On executing the above code we get the below output.
Writing a tab depmited file
In order to write a tab depmited file we can use the dlm option with a value "tab". The following code writes the file car_tab.txt.
proc export data = sashelp.cars outfile = /folders/myfolders/sasuser.v94/TutorialsPoint/car_tab.txt dbms = csv; run;
Data can also be written as HTML file which we will see under the output depvery system chapter.
Advertisements