SAS (Base SAS)+
data DUMMY01;
infile datalines dlm='|' dsd missover;
input grouplabel : $100. statistic : $100. group : best32. intord : best32.;
label ;
format ;
datalines4;
Sex, n(%)|Male|2|1
Sex, n(%)|Female|2|2
Sex, n(%)|Missing|2|99
;;;;
run;
data DUMMY_TREATMENTS;
infile datalines dlm='|' dsd missover;
input treatment : best32.;
label ;
format ;
datalines4;
1
2
3
4
;;;;
run;
proc sql;
create table dummy02 as
select *
from dummy01,dummy_treatments;
quit;
infile datalines dlm='|' dsd missover;
input grouplabel : $100. statistic : $100. group : best32. intord : best32.;
label ;
format ;
datalines4;
Sex, n(%)|Male|2|1
Sex, n(%)|Female|2|2
Sex, n(%)|Missing|2|99
;;;;
run;
data DUMMY_TREATMENTS;
infile datalines dlm='|' dsd missover;
input treatment : best32.;
label ;
format ;
datalines4;
1
2
3
4
;;;;
run;
proc sql;
create table dummy02 as
select *
from dummy01,dummy_treatments;
quit;
- To build a Cartesian product in SAS, we can write a DATA step that reads one dataset in full and, for each observation, loops through every observation of the other.
- A compact alternative is
PROC SQL; create table x as select * from a, b; quit;— SQL’s comma-join syntax is a Cartesian product by default. - Another option is two
SETstatements withpoint=and adoloop — more code but avoids SQL if we prefer DATA-step syntax. - All three approaches produce the same output: every row of one input paired with every row of the other.
- Expected row count is n1 * n2 — we check this before trusting the result.