Kore Tech Tip
How to Use SAMPLE Command for Data Analysis
Tip
#1006

Using SAMPLE and EQ in SELECT and LIST statements

SELECT Verb Options

The SELECT verb has some powerful and useful options that can make life easier when attempting to gather data for analysis. One of these is the SAMPLE option. When you are developing RETRIEVE reports, it is often useful to look at sample data to determine such things as field length, column header descriptions, etc. You can use the SAMPLE option with the SELECT verb to gather a representative sample of any file. Below is an example of the use of this option:
>SELECT SOLI SAMPLE 5
5 records selected to list 0.

>
Another useful feature of RETRIEVE is the ability to compare the contents of different fields of the same record. Below is an example of this, where we are seeking records where the total ordered quantity EQ the total open quantity (Note: UniData users are required to use the lower case version of the verb – invoking the native UniData behavior -- to make this work):
>list SOLI WITH F11 EQ F39 F11 F39
5 records selected to list 0.

08:10:01 JAN 08 2003 1
SOLI...... Total Ordered Quantity Total Open Quantity

187998*2                       10                  10
201157*1                       10                  10
201157*2                       10                  10
201157*3                        3                   3
201157*4                       10                  10
183984*2                        2                   2

Enter  to continue...

Using SAMPLE AND SAMPLED

On UniData and UniVerse, you can also use SAMPLE with the LIST or SORT verbs to limit the volume of data reported on. The syntax is the same on both RDBMS systems:
SAMPLE [n]
The first n records from the file are selected and listed, e.g.
>LIST PARTS DESC SAMPLE 5
SAMPLED provides slightly different behavior
SAMPLED [n]
Selects every nth record from the file, e.g.
>LIST PARTS DESC SAMPLED 5
Note the SORT verb with the SAMPLE (or SAMPLED) command works the same as always, that is, it selects the records, builds a sorted list, and then displays the data.

UniData and UniVerse are products, copyrights and trademarks of Rocket Software
 
 
 
Our technical tips are provided to help you find new or easier ways to solve some of your technical challenges or to show you a new technique. We hope you find them useful. Please contact us if you would like to share one of your Tech Tips or need help solving a technical challenge. We would be happy to help you.