You
can use the SELECT statement to browse CA-Datacom/DB data that is described by a view descriptor. The query in the following example
retrieves and displays all the fields and records
in the Customers table that are described by the Vlib.UsaCust view descriptor. The
UNDO_POLICY option is included to disable member-level locking and
to enable updates later in the PROC SQL execution. You can exclude the UNDO_POLICY
option if you do not plan to perform updates. The LINESIZE= system option is used
to reset the default output width to 120 columns.
Note: The following SQL procedure
examples assume that the CUSTOMERS table has not been updated by the
earlier SAS/FSP examples.
options linesize=120;
proc sql undo_policy=none;
title 'CA-Datacom/DB Data Output from a SELECT Statement';
select custnum, state label='STATE', zipcode label='ZIPCODE',
name, firstord
from vlib.usacust;
The following output shows the query's results. Notice that the SQL procedure displays
the CA-Datacom/DB
field names, not the corresponding SAS
column names.
Results of a PROC SQL Query
CA-Datacom/DB Data Output from a SELECT Statement
CUSTOMER STATE ZIPCODE NAME FIRSTORDERDATE
------------------------------------------------------------------------------------------------------
12345678 NC . .
14324742 CA 95123 SANTA CLARA VALLEY TECHNOLOGY SPECIALISTS 05FEB65
19783482 VA 22090 TWENTY-FIRST CENTURY MATERIALS 18JUL68
14898029 MD 20850 UNIVERSITY BIOMEDICAL MATERIALS 12NOV76
19876078 CA 93274 SAN JOAQUIN SCIENTIFIC AND INDUSTRIAL SUPPLY, INC. 11MAY79
18543489 TX 78701 LONE STAR STATE RESEARCH SUPPLIERS 10SEP79
14569877 NC 27514 PRECISION PRODUCTS 15AUG83
15432147 MI 49001 GREAT LAKES LABORATORY EQUIPMENT MANUFACTURERS 28APR86
You can specify a WHERE
clause as part of the SELECT statement to subset the records for display.
This example displays the companies that are located in North Carolina.
title 'CA-Datacom/DB Data Output Subset by a WHERE Clause';
select custnum, state label='STATE', zipcode label='ZIPCODE',
name, firstord
from vlib.usacust
where state='NC';
Notice that the PROC
SQL statement is not repeated in this query. You do not need to repeat
the PROC statement unless you use another SAS procedure, the DATA
step, or a QUIT statement between PROC SQL statements. The following
output displays the two companies from North Carolina described by
Vlib.UsaCust.
Results of PROC SQL Query Subset by a WHERE Clause
CA-Datacom/DB Data Output Subset by a WHERE Clause
CUSTOMER STATE ZIPCODE NAME FIRSTORDERDATE
---------------------------------------------------------------
12345678 NC . .
14569877 NC 27514 PRECISION PRODUCTS 15AUG83