Sample 25447: Demonstrates basic SQL INSERT statements
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample is from the SAS Sample Library. For additional information refer to SAS Help and Online Documentation.
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: SQLINSRT */
/* TITLE: Demonstrates Basic SQL Insert Statements */
/* PRODUCT: BASE */
/* SYSTEM: ALL */
/* KEYS: SQL DATMAN INSERT GROUP BY */
/* PROCS: SQL */
/* DATA: */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: */
/* */
/****************************************************************/
/* The first step is to create the Paper table which will be */
/* used in the following queries. */
data paper;
input author$1-8 section$9-16 title$17-43 @45 time time5.
duration;
format time time5.;
label title='Paper Title';
cards;
Tom Testing Automated Product Testing 9:00 35
Jerry Testing Involving Users 9:50 30
Nick Testing Plan to test, test to plan 10:30 20
Peter Info SysArtificial Intelligence 9:30 45
Paul Info SysQuery Languages 10:30 40
Lewis Info SysQuery Optimisers 15:30 25
Jonas Users Starting a Local User Group 14:30 35
Jim Users Keeping power users happy 15:15 20
Janet Users Keeping everyone informed 15:45 30
Marti GraphicsMulti-dimensional graphics 16:30 35
Marge GraphicsMake your own point! 15:10 35
Mike GraphicsMaking do without color 15:50 15
Jane GraphicsPrimary colors, use em! 16:15 25
;
proc sql;
/* There are two methods for inserting data into SAS datasets */
/* 1) by inserting constant values */
/* 2) by inserting the values selected with a SQL select */
/* A new paper has been submitted by Jost on Foreign */
/* Language Issues. */
/* Here we insert constant values */
insert into paper(author, title, time)
values('Jost', 'Foreign Language Issues', '11:15't);
title2 'After inserting Jost';
select * from paper;
/* A new table, Counts, is created which contains the */
/* section and number of papers for each section. */
/* Here we insert the results of the sql select expression. */
create table counts( section char(20), papers num );
insert into counts
select section, count(*)
from paper
group by section;
title2 ' Papers counted by section';
select * from counts;
quit;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
After inserting Jost
author section Paper Title time duration
----------------------------------------------------------------
Tom Testing Automated Product Testing 9:00 35
Jerry Testing Involving Users 9:50 30
Nick Testing Plan to test, test to plan 10:30 20
Peter Info Sys Artificial Intelligence 9:30 45
Paul Info Sys Query Languages 10:30 40
Lewis Info Sys Query Optimisers 15:30 25
Jonas Users Starting a Local User Group 14:30 35
Jim Users Keeping power users happy 15:15 20
Janet Users Keeping everyone informed 15:45 30
Marti Graphics Multi-dimensional graphics 16:30 35
Marge Graphics Make your own point! 15:10 35
Mike Graphics Making do without color 15:50 15
Jane Graphics Primary colors, use em! 16:15 25
Jost Foreign Language Issues 11:15 .
Papers counted by section
section papers
------------------------------
1
Graphics 4
Info Sys 3
Testing 3
Users 3
This example demonstrates basic SQL INSERT Statements.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SQL
|
Date Modified: | 2005-08-24 16:06:34 |
Date Created: | 2005-05-23 13:54:24 |
Operating System and Release Information
SAS System | Base SAS | All | n/a | n/a |