forked from Jiangtang/Programming-SAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cartesian Product datastep.sas
51 lines (42 loc) · 1.2 KB
/
Cartesian Product datastep.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
/*http://support.sas.com/kb/24/652.html*/
/* Create two test data sets */
data one;
input id $ fruit $;
datalines;
a apple
a apple
b banana
c coconut
c coconut
c coconut
;
data two;
input id $ color $;
datalines;
a amber
b brown
b black
c cocoa
c cream
;
data every_combination;
/* Set one of your data sets, usually the larger data set */
set one;
do i=1 to n;
/* For every observation in the first data set, */
/* read in each observation in the second data set */
set two point=i nobs=n;
output;
end;
run;
proc print data=every_combination;
run;
proc sql;
create table three as
select one.*
,two.color
from one
,two;
quit;
proc print data=three;
run;