Note: Alternatively, you can set the SQLUNDOPOLICY system option. For more
information, see “SQLUNDOPOLICY= System Option” on page 383.
Deleting Rows
The DELETE statement deletes one or more rows in a table or in a table that underlies a
PROC SQL or SAS/ACCESS view. For more information about deleting rows from
views, see “Updating a View” on page 132. The following DELETE statement deletes
the names of countries that begin with the letter R:
/* Create and populate Newcountries */
proc sql;
create table sql.newcountries like sql.countries;
insert into sql.newcountries
select * from sql.countries
where population ge 130000000;
proc sql;
delete
from sql.newcountries
where name like 'R%';
A note in the SAS log tells you how many rows were deleted.
Log 4.4 SAS Log for the DELETE Statement
NOTE: 1 row was deleted from SQL.NEWCOUNTRIES.
Note: For PROC SQL tables, SAS deletes the data in the rows but retains the space in
the table.
CAUTION:
If you omit a WHERE clause, then the DELETE statement deletes all the rows
from the specified table or the table that is described by a view. The rows are
not deleted from the table until it is re-created.
Altering Columns
The ALTER TABLE statement adds, modifies, and deletes columns in existing tables.
You can use the ALTER TABLE statement with tables only; it does not work with views.
A note appears in the SAS log that describes how you have modified the table.
Adding a Column
The ADD clause adds a new column to an existing table. You must specify the column
name and data type. You can also specify a length (LENGTH=), format (FORMAT=),
informat (INFORMAT=), and a label (LABEL=). The following ALTER TABLE
statement adds the numeric data column Density to the NewCountries table:
proc sql;
create table sql.newcountries like sql.countries;
insert into sql.newcountries
Altering Columns 123