![]() | ![]() | ![]() | ![]() | ![]() |
Note:
PROC EXPORT is only available on the following operating
systems: OS/2, UNIX, OpenVMS and WINDOWS. For other operating
systems, see
Macro to create a comma delimited file,
Robust macro to create a comma delimited file, or
How can I create a CSV file with ODS?
.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/*********************************************************************************/
/* This example of PROC EXPORT will write out an external file that is */
/* exclamation point (!) delimited with variable names written to the first */
/* row. */
/* */
/* The DATA= value is the name of the SAS data set you want to write out */
/* to an external file. The OUTFILE= value is the location of the external */
/* file you are creating. The DBMS= value is the type of file you are */
/* creating. DBMS=DLM indicates a delimited file is to be created. */
/* By default, the delimiter will be a blank. To override this default, */
/* specify a value for the DELIMITER= option. For an ASCII TAB delimited */
/* file use DELIMITER='09'x. For an EBCDIC TAB delimited file use */
/* DELIMITER='05'x. DBMS=CSV will generate a comma delimited file so */
/* DELIMITER= is not required in this case. */
/* */
/* REPLACE tells SAS to overwrite an existing external file of the same name. */
/* */
/* Currently there is no statement in PROC EXPORT to control whether variable */
/* names are written out to the first row of the external file or not. Variable */
/* names are always written on the first row of the file. However, if running */
/* interactively, you can recall the DATA step code generated by PROC EXPORT */
/* (RUN --> Recall Last Submit) and comment out the IF condition responsible */
/* for writing out the variable names on the first iteration of the step. */
/* Resubmit. */
/*********************************************************************************/
/* Example 1 */
proc export
data=sashelp.class
outfile='pathname.ext'
dbms=dlm
replace;
delimiter='!';
run;
/* This example of PROC EXPORT will create a CSV file. Since the */
/* DBMS= value is CSV, you do not have to use the DELIMITER= statement. */
/* Example 2 */
proc export
data=sashelp.class
outfile='pathname.ext'
dbms=csv
replace;
run;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
OUTPUT to external file -- Example 1 Name!Sex!Age!Height!Weight Alice!F!13!56.5!84 Barbara!F!13!65.3!98 Carol!F!14!62.8!102.5 Jane!F!12!59.8!84.5 Janet!F!15!62.5!112.5 Joyce!F!11!51.3!50.5 Judy!F!14!64.3!90 Louise!F!12!56.3!77 Mary!F!15!66.5!112 Alfred!M!14!69!112.5 Henry!M!14!63.5!102.5 James!M!12!57.3!83 Jeffrey!M!13!62.5!84 John!M!12!59!99.5 Philip!M!16!72!150 Robert!M!12!64.8!128 Ronald!M!15!67!133 Thomas!M!11!57.5!85 William!M!15!66.5!112 OUTPUT to external file -- Example 2 Name,Sex,Age,Height,Weight Alice,F,13,56.5,84 Barbara,F,13,65.3,98 Carol,F,14,62.8,102.5 Jane,F,12,59.8,84.5 Janet,F,15,62.5,112.5 Joyce,F,11,51.3,50.5 Judy,F,14,64.3,90 Louise,F,12,56.3,77 Mary,F,15,66.5,112 Alfred,M,14,69,112.5 Henry,M,14,63.5,102.5 James,M,12,57.3,83 Jeffrey,M,13,62.5,84 John,M,12,59,99.5 Philip,M,16,72,150 Robert,M,12,64.8,128 Ronald,M,15,67,133 Thomas,M,11,57.5,85 William,M,15,66.5,112
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Procedures ==> EXPORT Common Programming Tasks ==> Reading and Writing External Data |
| Date Modified: | 2008-02-08 16:18:25 |
| Date Created: | 2004-09-30 14:09:15 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | Base SAS | Tru64 UNIX | 8 TS M0 | n/a |
| Solaris | 8 TS M0 | n/a | ||
| OpenVMS Alpha | 8 TS M0 | n/a | ||
| HP-UX IPF | 8 TS M0 | n/a | ||
| Linux | 8 TS M0 | n/a | ||
| HP-UX | 8 TS M0 | n/a | ||
| AIX | 8 TS M0 | n/a | ||
| ABI+ for Intel Architecture | 8 TS M0 | n/a | ||
| 64-bit Enabled Solaris | 8 TS M0 | n/a | ||
| 64-bit Enabled HP-UX | 8 TS M0 | n/a | ||
| 64-bit Enabled AIX | 8 TS M0 | n/a | ||
| OS/2 | 8 TS M0 | n/a | ||





