Previous Page | Next Page

Processing an ESDS in a SAS Job

Adding Records to an ESDS

Add records to an existing ESDS using the following method:

  1. Specify the VSAMUPDATE system option.

  2. Include both an INFILE and a FILE statement for the data set. Specify the VSAM option in both the INFILE and the FILE statements. Specify all other options in the INFILE statement, which must precede the FILE statement.

For a list of the options that you can use to add records to an ESDS, see SAS Options for an ESDS.

You do not have to include an INPUT statement with the INFILE statement. The INPUT statement is unnecessary because you do not have to read a record in order to add a new record. Here is an example:

data three;
   infile myesds vsam ;
   file myesds vsam ;
   id='289478363';
   lastname='Cox          ';
   frstname='June        ';
   address='Rt. 2 Box 784 ';
   city='Cheyenne';
   state='WY';
   zip='59334 ';
   balance='00100';
   gpa='2.33';
   class='SE';
   hrs='13';
   finaid='Y';
   if _n_=1 then newstu=0;

   put @1  id       $9.   /* Student's Social Security number        */
       @10 lastname $10.  /* Student's surname                       */
       @20 frstname $10.  /* Student's given name                    */
       @30 address  $25.  /* Permanent mailing address               */
       @55 city     $15.  /* City of residence                       */
       @70 state    $2.   /* State of residence                      */
       @72 zip      $5.   /* Five-digit ZIP code                     */
       @77 balance  $5.   /* Balance from previous semester (if any) */
       @82 gpa      $4.   /* Grade point average on a 4.00 scale     */
       @86 class    $2.   /* FR, SO, JU, SE, or, GR                  */
       @88 hrs      $2.   /* Hours registered for in next semester   */
       @90 finaid   $1.;  /* Financial aid eligibility, Y or N       */
   newstu=newstu+1;
   retain newstu;
   ...more SAS statements...
run;

In the example, a record for a new student, JUNE COX, is defined and added to the MYESDS data set without first reading the ESDS. The record is added to the end of the data set because output access is always sequential when new records are added to an ESDS. (See Access Types for ESDS Operations).

Previous Page | Next Page | Top of Page