Log 4.1 Table Created from Column Definitions
1 proc sql;
2 describe table sql.newstates;
NOTE: SQL table SQL.NEWSTATES was created like:
create table SQL.NEWSTATES( bufsize=4096 )
(
state char(2),
date num format=DATE9. informat=DATE9.,
population num
);
DESCRIBE TABLE writes a CREATE TABLE statement to the SAS log even if you did
not create the table with the CREATE TABLE statement. You can also use the
CONTENTS statement in the DATASETS procedure to get a description of NewStates.
Creating Tables from a Query Result
To create a PROC SQL table from a query result, use a CREATE TABLE statement with
the AS keyword, and place it before the SELECT statement. When a table is created this
way, its data is derived from the table or view that is referenced in the query's FROM
clause. The new table's column names are as specified in the query's SELECT clause list.
The new table’s column attributes (the type, length, informat, format, and extended
attributes) are the same as the selected source columns.
Note: Extended attributes are not copied to tables that are created using multi-table joins
or outer joins. When UNION, INTERSECT, or minus operators are used, extended
attributes are copied only if the table that is listed before the UNION, INTERSECT,
or minus operator has extended attributes.
The following CREATE TABLE statement creates the Densities table from the Countries
table. The newly created table is not displayed in SAS output unless you query the table.
Note the use of the OUTOBS option, which limits the size of the Densities table to 10
rows.
libname sql 'SAS-library';
proc sql outobs=10;
title 'Densities of Countries';
create table sql.densities as
select Name 'Country' format $15.,
Population format=comma10.0,
Area as SquareMiles,
Population/Area format=6.2 as Density
from sql.countries;
select * from sql.densities;
Creating Tables 113