SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Quiz: Reading Variable-Length Records

Select the best answer for each question and click Score My Quiz.

  1. Variable-length records

     a.   have an end-of-record marker at the end of the last field.
     b.   do not have a predetermined number of columns.
     c.   can use space more efficiently than fixed-length records.
     d.   all of the above

  2. Which of the following is not true for the LENGTH= option?

     a.   It is used in the INFILE statement.
     b.   It determines the total length of each record.
     c.   It defines a variable that is stored as part of each observation.
     d.   It defines a numeric variable.

  3. Which SAS statement reads the values for SSN (in the first field) and holds the current record until the DATA step begins the next iteration?

    1---+----10---+----20---+
    182-04-7814ASPDEN530
    302-57-5023ATWOOD480
    123-89-8470BROSNAN560

     a.  
    input SSN $ 1-11;
     b.  
    input SSN $ 1-11 @; 
     c.  
    input SSN $ 1-11 @@;
     d.  
    input @1 SSN 11.; 

  4. Which SAS statement creates a variable, named namelen, whose value is the width of Name (in the second field) in each record? Assume that the total length of each record is assigned to a variable named reclen.

    1---+----10---+----20---+
    182-04-7814ASPDEN530
    302-57-5023ATWOOD480
    123-89-8470BROSNAN560

     a.  
    namelen=reclen;                    
     b.  
    namelen=reclen-3;                    
     c.  
    namelen=reclen-10;                    
     d.  
    namelen=reclen-14;                     

  5. Which SAS statement correctly reads the values for Name (in the second field) and Score (in the third field)? Assume that the variable namelen is used to determine the width of the Name field in each record.

    1---+----10---+----20---+
    182-04-7814ASPDEN530
    302-57-5023ATWOOD480
    123-89-8470BROSNAN560

     a.  
    input name $varying7. namelen score 3.; 
     b.  
    input name $7. namelen score 3.; 
     c.  
    input name $varying7. score 3.; 
     d.  
    input name $varying6. namelen score 3.; 

  6. What happens when the values for Name and Office are read during the second iteration of the DATA step?

    Program Dada Vector

    1---+----10---+----20
    3124Feldman1014
    2112Fruchtenicht1015
    1018Goodyear1013
    2809Hardin1018
    3205Matti1016
    data perm.offices;
       infile location length=reclen;
       input ID 4. @;
       namelen=reclen-8;
       input Name $varying10. namelen Office;
    run; 

     a.   The correct values for Name and Office are read into the program data vector.
     b.   An incorrect value for Name and the correct value for Office are read into the program data vector.
     c.   An incorrect value for Name is read into the program data vector and the value for Office is set to missing.
     d.   none of the above

  7. Variable-length records can contain . . .

     a.   fields of varying lengths.
     b.   varying numbers of fields.
     c.   both a and b
     d.   none of the above

  8. Which SAS statement repetitively executes other statements based on the value of an index-variable named index? Each repeating block of values for Date (in the second field) and Score (in the third field) needs to be read until the end of the current record. (HINT: The length of each record is assigned to a variable named reclen.)

    1---+----10---+----20---+----30---+-
    182-04-7814 09FEB98 530
    302-57-5023 09FEB98 480 04MAY98 530

     a.  
    do index=13 to reclen; 
     b.  
    do index=11 to reclen by 12;
     c.  
    do index=13 to reclen by 11; 
     d.  
    do index=13 to reclen by 12; 

  9. When does this iterative DO loop stop executing?
     do index=7 to reclen by 10;
        .
        .
        .
     end; 

     a.   When index is equal to reclen.
     b.   When index exceeds reclen.
     c.   When the END statement executes.
     d.   When reclen exceeds index.

  10. Which set of statements correctly completes the DO loop?

    1---+----10---+----20---+----30---+----40---+----50---+
    102697 12JUN98 $210.73 12JUL98 $210.73
    105898 30SEP98 $399.84
    117397 15MAR99 $128.08 16APR99 $128.08 16MAY99 $127.01
     data perm.customers;
        infile payments length=reclen;
        input ID 6. @;
        do index=8 to reclen by 16;
        ?
        ?
        ? 
     run; 

     a.  
       input Date : date. Amount comma7. @;
       output;
    end;
     
     b.  
       input Date : date. Amount comma7.;
       output;
    end;
     
     c.  
       input Date : date. Amount comma7. @;
    end;
     
     d.  
       input Date : date. Amount comma7.;
    end;
    output;
     



back||next

Terms of Use & Legal Information | Privacy Statement