Previous Page | Next Page

The SQL Procedure

Example 1: Creating a Table and Inserting Data into It


Procedure features:

CREATE TABLE statement

column-modifier

INSERT statement

VALUES clause

SELECT clause

FROM clause

Table: PROCLIB.PAYLIST

This example creates the table PROCLIB.PAYLIST and inserts data into it.


Program

 Note about code
libname proclib 'SAS-library';
 Note about code
options nodate pageno=1 linesize=80 pagesize=40;
 Note about code
proc sql;
   create table proclib.paylist
       (IdNum char(4),
        Gender char(1),
        Jobcode char(3),
        Salary num,
        Birth num informat=date7.
                  format=date7.,
        Hired num informat=date7.
                  format=date7.);
 Note about code
insert into proclib.paylist
    values('1639','F','TA1',42260,'26JUN70'd,'28JAN91'd)
    values('1065','M','ME3',38090,'26JAN54'd,'07JAN92'd)
    values('1400','M','ME1',29769.'05NOV67'd,'16OCT90'd)
 Note about code
    values('1561','M',null,36514,'30NOV63'd,'07OCT87'd)
    values('1221','F','FA3',.,'22SEP63'd,'04OCT94'd);
 Note about code
   title 'PROCLIB.PAYLIST Table';
 Note about code
select *
   from proclib.paylist;

Output: Listing

                             PROCLIB.PAYLIST Table

               Id
               Num   Gender  Jobcode    Salary    Birth    Hired
               -------------------------------------------------
               1639  F       TA1         42260  26JUN70  28JAN91
               1065  M       ME3         38090  26JAN54  07JAN92
               1400  M       ME1         29769  05NOV67  16OCT90
               1561  M                   36514  30NOV63  07OCT87
               1221  F       FA3             .  22SEP63  04OCT94

Output: HTML

[untitled graphic]

Previous Page | Next Page | Top of Page