With
the SET clause, you assign values to columns by name. The columns
can appear in any order in the SET clause. The following INSERT statement
uses multiple SET clauses to add two rows to NEWCOUNTRIES:
libname sql 'SAS-library';
proc sql;
create table sql.newcountries
like sql.countries;
proc sql;
title "World's Largest Countries";
insert into sql.newcountries
select * from sql.countries
where population ge 130000000;
proc sql;
insert into sql.newcountries
set name='Bangladesh',
capital='Dhaka',
population=126391060
set name='Japan',
capital='Tokyo',
population=126352003;
title "World's Largest Countries";
select name format=$20.,
capital format=$15.,
population format=comma15.0
from sql.newcountries;
Rows Inserted with the SET Clause
Note the following features
of SET clauses:
-
As with other SQL clauses, use
commas to separate columns. In addition, you must use a semicolon
after the last SET clause only.
-
If you omit data for a column,
then the value in that column is a missing value.
-
To specify that a value is missing,
use a blank in single quotation marks for character values and a period
for numeric values.