NC STATE University
Department of Statistics


SAS FAQ: How can I Export SAS Data Sets? ,
SAS version 6.12, and version 7

Ok, here is the scoop on exporting SAS data sets.

Note:
Appropriate LIBNAME statements must be issued before exporting SAS data
sets. What is a LIBNAME statement? 



USING THE DEXPORT COMMAND - UNIX or PC My favorite method of exporting is the "dexport" command-line command. It eliminates programming and all the menus! It creates a tab delimited text file that can be imported into EXCEL, but regretfully, not into ACCESS( at least I couldn't figure out how.) Syntax: On the command line: dexport libref.dsn 'filename.txt' Example: dexport mylib.part1 'part1.txt' Explanation In this example, "mylib" is a libref, "part1" is the name of a SAS data set, and "part1.txt" is the name of the tab delimited text file being created. If you do not know what a libref is, review LIBNAME statements above.
USING PULL DOWN MENUS - PC SAS VERSION 6.12
In PC SAS version 6.12, with the FILE-->EXPORT menus  you can export to:
Filetype                  File Extension 
dbase                         .dbf
EXCEL 5 or  7                 .xls
EXCEL 4                       .xls
Lotus 1                       .wks1
Lotus 3                       .wks3
Lotus 4                       .wks4
Space delimited text file     .dat
Comma Delimited Text File     .csv
Tab delimited Text File       .txt

USING PULL DOWN MENUS - PC SAS VERSION 7
In PC SAS, Version 7, with the File-->Export menus you can export to:
Filetype            File Extension 
All the Above plus-
Excel 97                .xls
Microsoft Access        .mdb

USING PULL DOWN MENUS - UNITY SAS 6.12
SAS 6.12 on UNITY, with the File-->Export menus you can export to:
Filetype          File Extension 
dbase                .dbf
space delimited      .dat
commma delimited     .csv
tab delimited        .txt

USING PROGAMMING STATEMENTS - UNIX or PC
With program statements you can create:
Filetype         File Extension 
space delimited     .dat
comma delimited     .csv
tab delimited       .txt
Example: This creates a tab delimited text file named file1.txt
Filename out 'file1.txt';
data _null_; set a;
file out;
put var1 (var2-var10) ('09'x);
run;

SPSS AND BMDP
SAS can read SPSS and BMDP data sets that are stored as "portable files" but it can't write them.

Go to: SAS Consulting Home Page
           Department of Statistics Home Page

Maintained by: Sandy Donaghy and Joy Smith
Last Modified: March 29, 1999