-
Notifications
You must be signed in to change notification settings - Fork 0
/
week7_2(inserting data).sas
62 lines (48 loc) · 1.35 KB
/
week7_2(inserting data).sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
7_1은 테이블을 만들었고
7_2는 inserting data in the table
방법은 3가지
- set 여러 컬럼 한 row씩
- values 여러 컬럼 한 rows
- query-expression (select, from)
*/
/*method1 set*/
proc sql;
insert into discount
set Destination = 'LHR'
, BeginDatae = '01Mar2000'd
, EndDatae = '05Mar2000'd
,Discount = .33
set Destination = 'CPH'
, BeginDatae = '03Mar2000'd
, EndDatae = '10Mar2000'd
,Discount = .15 ;
quit;
/*method2 values 사용, set보다 편리하네*/
/*values의 갯수와 컬럼의 갯수가 일치해야함*/
proc sql;
insert into discount (Destination, BeginDate, EndDate, Discount)
values('LHR', '01Mar2000'd, '05Mar2000'd, .33)
values('CPH', '03Mar2000'd, '10Mar2000'd, .15 );
quit;
/* method 3*/
/*컬럼 갯수와 select 문의 컬럼의 갯수가 일치해야 해*/
proc sql;
insert into discount(Destination, Discount)
select Destination, Rate*.25
from work.fares
where Type = 'special';
quit;
/* create table + insert data*/
proc sql;
create table discount1 /*define table*/
(Destination char(3)
, BeginDate date label = 'BEGINS'
, EndDate date label = 'ENDS'
, Discount num);
insert into discount1 /*insert data*/
values('LHR', '01Mar2000'd, '05Mar2000'd, .33)
values('CPH', '03Mar2000'd, '10Mar2000'd, .15 );
select * /*printing out data*/
from discount1;
quit;