?? sqlinsrt.sas
字號:
/****************************************************************/ /* 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: KMS, PMK UPDATE: */ /* REF: */ /* MISC: */ /* */ /****************************************************************/ title1 '*** sqlinsrt: basic SQL insert statements ***'; /*---------------------------------------------------------------*/ /*-- 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 35Jerry Testing Involving Users 9:50 30Nick Testing Plan to test, test to plan 10:30 20Peter Info SysArtificial Intelligence 9:30 45Paul Info SysQuery Languages 10:30 40Lewis Info SysQuery Optimisers 15:30 25Jonas Users Starting a Local User Group 14:30 35Jim Users Keeping power users happy 15:15 20Janet Users Keeping everyone informed 15:45 30Marti GraphicsMulti-dimensional graphics 16:30 35Marge GraphicsMake your own point! 15:10 35Mike GraphicsMaking do without color 15:50 15Jane 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;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -