Database Reference
In-Depth Information
Figure 2.4: SAS Code to Export to Version 4 and 5 Excel Files.
* Write an Excel4 formatted file;
PROC EXPORT DATA=sashelp.shoes
OUTFILE='C:\My_Files\shoes_to_Excel_4_file.xls'
DBMS=EXCEL4
REPLACE;
RUN;
* Write an Excel5 formatted file;
PROC EXPORT DATA=sashelp.shoes
OUTFILE='C:\My_Files\shoes_to_Excel_5_file.xls'
DBMS=EXCEL5
REPLACE;
RUN;
Example 2.2 PROC EXPORT Using the DBMS=DLM Option
This example uses PROC EXPORT to write a delimited file readable by Microsoft Excel. This example
does not produce an Excel file; however, it produces a comma-delimited *.csv formatted file that can be
read by Microsoft Excel. Using the SAS External File Interface (EFI), the following code writes out a
delimited file from the SASHELP.shoes data set. Any character could have been used here. Using a comma
makes the output file the same as if the DBMS=CSV option were used without the DELILITER=”,”
statement. Using DBMS =TAB would produce a similar file with Tab characters instead of commas.
Figure 2.5: SAS Code to Export to CSV File.
PROC EXPORT DATA=sashelp.shoes
OUTFILE='C:\My_Files\Shoes.csv'
DBMS=DLM
REPLACE;
DELIMITER=',';
PUTNAMES=NO;
RUN;
Figure 2.6: The Output Log Produced by the PROC EXPORT Code.
1 PROC EXPORT DATA=sashelp.shoes
2 OUTFILE='C:\My_Files\Shoes.csv'
3 DBMS=DLM
4 REPLACE;
5 DELIMITER=',';
6 PUTNAMES=NO;
7 RUN;
8 /**********************************************************************
9 * PRODUCT: SAS
10 * VERSION: 9.3
11 * CREATOR: External File Interface
12 * DATE: 11JAN14
13 * DESC: Generated SAS Datastep Code
14 * TEMPLATE SOURCE: (None Specified.)
15 ***********************************************************************/
16 data _null_;
17 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
18 %let _EFIREC_ = 0; /* clear export record count macro variable */
19 file 'C:\My_Files\Shoes.csv' delimiter=',' DSD DROPOVER lrecl=32767;
20 set SASHELP.SHOES end=EFIEOD;
21 format Region $25. ;
22 format Product $14. ;
23 format Subsidiary $12. ;
24 format Stores best12. ;
25 format Sales dollar12. ;
26 format Inventory dollar12. ;
 
Search WWH ::




Custom Search