1 SAMPLE_$

  SAMPLE invokes the WESTAT Sampling Utility, which will create a 
 new file of records which consists of a probability sample of another
 file.  There are three types of sampling methodologies available,
 SIMPLE, EXACT, and SYSTEMATIC.  

  The utility prompts for the type of sampling methodology, and for 
 the input and output file names.  Current device and directory defaults 
 are assumed unless otherwise specified.  Input filenames have a default 
 type of ".DAT", output filenames have a default type of ".SMP".  If a 
 tape drive is allocated  and a tape mounted, the tape may be used for 
 input or output.

  Sampling is performed with the aid of pseudo-random numbers generated
 by the system service MTH$RANDOM, using a seed supplied by the user.  
 As a default, the binary value of the system time is used as the seed.
 If the default is used, the sample cannot be reconstructed from the
 original seed.  A user-supplied seed should be a five or six digit
 odd number.

2 SIMPLE

  For a simple sample each record is read and written to the sample
 file with a fixed probability equal to a fraction entered in 
 response to a prompt.  MTH$RANDOM is called once for each record
 and the record is written to the sample file if the number returned
 is less than the fraction entered by the user.

     Example:

$ SAMPLE
                             WESTAT SAMPLE UTILITY

   Enter type of sample (SIMPLE,EXACT, or SYSTEMATIC):  SIMPLE
   Input file:   FILE.DAT
   Output file:  SAMPLE.DAT
   Enter fraction of records to be sampled:  0.02
   Enter seed for random number (<ret> for system default):  

%SMP-S-RECSREAD, 1000 records sampled from DRC1:[USERNAME]FILE.DAT;2
%SMP-S-WRITTEN, 19 records written to DRC1:[USERNAME]SAMPLE.DAT;1.
$

2 EXACT

  An exact size probability sample can be created through this 
 facility.  The user is prompted for an exact number of records
 to be selected.  As each record is read from the input file it is
 selected with a probability equal to the fraction whose numerator
 is the number of records remaining to be selected and whose
 denominator is the number of remaining records.  For example,
 if 10 records are to be selected from a file of 100, the first
 record is selected with a probability 10/100.  If the first
 record has been selected then the second record is selected 
 with a probability 9/99, but if the first record has not been
 selected the second record is selected with a probability of
 10/99, etc.  It can be shown that this method produces a
 sample where each record has an equal probability of being
 chosen.

     Example:

$ SAMPLE
                            WESTAT SAMPLE UTILITY

   Enter type of sample (SIMPLE, EXACT, or SYSTEMATIC):  EXACT
   Input file:   FILE.DAT
   Output file:  SAMPLE.DAT
   Number to be selected:  50
   Out of how many records? ("ALL" for all records)  ALL

 %SMP-I-ALLREC, 1000 records, entire file to be sampled.
   Enter seed for random number (<ret> for system default):

 %SMP-S-RECSREAD, 1000 records sampled from DRC1:[USERNAME]FILE.DAT;2
 %SMP-S-WRITTEN, 50 records written to DRC1:[USERNAME]SAMPLE.DAT;2.
$

2 SYSTEMATIC

  For a systematic sample the user is prompted for a sampling 
 increment, say 20.  A random integer between 1 and 20 is
 generated through a single call to MTH$RANDOM, say 13.
 As a result records 13, 33, 53, 73, etc. are written to the 
 sample file.
 
     Example:

$ SAMPLE
                            WESTAT SAMPLE UTILITY

   Enter sample type (SIMPLE, EXACT, or SYSTEMATIC):  SYSTEMATIC
   Input file:   FILE.DAT
   Output file:  SAMPLE.DAT
   Enter increment:  20
   Enter seed for random number (<ret> for system default):

 %SMP-S-RECSREAD, 1000 records sampled from DRC1:[USERNAME]FILE.DAT;2
 %SMP-S-WRITTEN, 50 records written to DRC1;[USERNAME]SAMPLE.DAT;3.
$
