Chapter Contents

Previous

Next
The EXPORT Procedure

Example 1: Exporting a Delimited External File


Procedure features:
PROC EXPORT statement arguments:
DATA=
DBMS=
OUTFILE=
Data source statement:
DELIMITER=

This example exports the following SAS data set named MYFILES.CLASS and creates a delimited external file:
                                  The SAS System                   1

   Obs    Name       Sex    Age    Height    Weight

     1    Alice       F      13     56.5       84.0
     2    Becka       F      13     65.3       98.0
     3    Gail        F      14     64.3       90.0
     4    Karen       F      12     56.3       77.0
     5    Kathy       F      12     59.8       84.5
     6    Mary        F      15     66.5      112.0
     7    Sandy       F      11     51.3       50.5
     8    Sharon      F      15     62.5      112.5
     9    Tammy       F      14     62.8      102.5
    10    Alfred      M      14     69.0      112.5
    11    Duke        M      14     63.5      102.5
    12    Guido       M      15     67.0      133.0
    13    James       M      12     57.3       83.0
    14    Jeffrey     M      13     62.5       84.0
    15    John        M      12     59.0       99.5
    16    Philip      M      16     72.0      150.0
    17    Robert      M      12     64.8      128.0
    18    Thomas      M      11     57.5       85.0
    19    William     M      15     66.5       112


Program
 Note about code
proc export data=myfiles.class
 Note about code
            outfile="/myfiles/class"
 Note about code
            dbms=dlm;
 Note about code
   delimiter='&';
run;


SAS Log
The SAS log displays the following information about the successful export. Notice the generated SAS DATA step.

12    /*********************************************************************
   12 ! *
   13    *   PRODUCT:   SAS
   14    *   VERSION:   8.00
   15    *   CREATOR:   External File Interface - Version 1.1
   16    *   DATE:      01MAR1999
   17    *   DESC:      Generated SAS Datastep Code
   18    *   TEMPLATE SOURCE:  (None Specified.)
   19    **********************************************************************
   19 ! */
   20       data _null_;
   21       set  MYFILES.CLASS                                   end=EFIEOD;
   22       %let _EFIERR_ = 0;     /* clear ERROR detection macro variable */
   23       %let _EFIREC_ = 0;     /* clear export record count macro variable
   23 ! */
   24       file '/myfiles/class' delimiter='&' DSD DROPOVER
   24 ! lrecl=32767;
   25          format NAME $8. ;
   26          format SEX $1. ;
   27          format AGE best12. ;
   28          format HEIGHT best12. ;
   29          format WEIGHT best12. ;
   30       if _n_ = 1 then        /* write column names */
   31        do;
   32          put
   33          'NAME'
   34          '&'
   35          'SEX'
   36          '&'
   37          'AGE'
   38          '&'
   39          'HEIGHT'
   40          '&'
   41          'WEIGHT'
   42          ;
   43        end;
   44        do;
   45          EFIOUT + 1;
   46          put NAME $ @;
   47          put SEX $ @;
   48          put AGE @;
   49          put HEIGHT @;
   50          put WEIGHT ;
   51          ;
   52        end;
   53       If _ERROR_ then        /* ERROR detection */
   54          call symput('_EFIERR_',1);
   55       If EFIEOD then
   56          call symput('_EFIREC_',EFIOUT);
   57       run;

   NOTE: Numeric values have been converted to character
         values at the places given by: (Line):(Column).
         53:31   55:31

   NOTE: 20 records were written to the file '/myfiles/class'.
         The minimum record length was 17.
         The maximum record length was 26.

   19 records created in /myfiles/class from MYFILES.CLASS.
   NOTE: /myfiles/class was successfully created.


Output
The external file produced by PROC EXPORT follows.

   NAME&SEX&AGE&HEIGHT&WEIGHT
   Alice&F&13&56.5&84
   Becka&F&13&65.3&98
   Gail&F&14&64.3&90
   Karen&F&12&56.3&77
   Kathy&F&12&59.8&84.5
   Mary&F&15&66.5&112
   Sandy&F&11&51.3&50.5
   Sharon&F&15&62.5&112.5
   Tammy&F&14&62.8&102.5
   Alfred&M&14&69&112.5
   Duke&M&14&63.5&102.5
   Guido&M&15&67&133
   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
   Thomas&M&11&57.5&85
   William&M&15&66.5&112


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.