/***************************************************************************************************************** SAS file name: cartesian_product File location: _________________________________________________________________________________________________________________ Purpose: To demonstrate how to create a cartesian product in SAS with the data step and PROC SQL Author: Peter Clemmensen Creation Date: 03/04/2019 This program supports the example page "SAS Cartesian Product with PROC SQL and the Data Step" on SASnrd.com *****************************************************************************************************************/ /* Create Example Data */ data test1; input id var1; datalines; 1 1 2 2 3 3 ; data test2; input id var2; datalines; 1 1 2 2 3 3 ; /* Cartesian product with PROC SQL */ proc sql; create table CartSQL as select test1.*, test2.var2 from test1, test2; quit; /* Cartesian product with the data step */ data CartDataStep; set test1; do i=1 to n; set test2 point=i nobs=n; output; end; run;