14.03.2014 Views

Using JMP - SAS

Using JMP - SAS

Using JMP - SAS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

94 Import Your Data Chapter 3<br />

Import Data from a Database<br />

Use the IN and BETWEEN Statements<br />

To specify a range of values to fetch, use the IN and BETWEEN statements in conjunction with WHERE. IN<br />

statements specify a list of values and BETWEEN lets you specify a range of values. For example,<br />

SELECT * FROM "Solubil$" WHERE LABELS IN (‘Methanol’, ‘Ethanol’, ‘Propanol’)<br />

fetches all rows that have values of the LABELS column Methanol, Ethanol, or Propanol.<br />

SELECT * FROM "Solubil$" WHERE ETH BETWEEN 0 AND 2<br />

fetches all rows that have ETH values between 0 and 2.<br />

Use the LIKE Statement<br />

With the LIKE statement, you can select values similar to a given string. Use % to represent a string of<br />

characters that can take on any value. For example, you might want to select chemicals out of the "Solubil$"<br />

data that are alcohols, that is, have the –ol ending. The following SQL statement accomplishes this task.<br />

SELECT * FROM "Solubil$" WHERE LABELS LIKE ‘%OL’<br />

The % operator can be placed anywhere in the LIKE statement. The following example extracts all rows that<br />

have labels starting with M and ending in OL:<br />

SELECT * FROM "Solubil$" WHERE LABELS LIKE ‘M%OL’<br />

Use Aggregate Functions<br />

Aggregate functions are used to fetch summaries of data rather than the data itself. Use any of the following<br />

aggregate functions in a SELECT statement.<br />

Table 3.3 SELECT Statement Functions<br />

Function<br />

SUM( )<br />

AVG( )<br />

MAX( )<br />

MIN( )<br />

COUNT( )<br />

Meaning<br />

Sum of the column<br />

Average of the column<br />

Maximum of the column<br />

Minimum of the column<br />

Number of rows in the column<br />

Some examples include:<br />

• The following statement requests the sum of the ETH and OCT columns:<br />

SELECT SUM(ETH), SUM(OCT) FROM "Solubil$"<br />

• This statement returns the number of rows that have ETH values greater than one:<br />

SELECT COUNT(*) FROM "Solubil$" WHERE ETH > 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!