This is the all combinations of multiple variables. In SQL procedure, there are two approach which are 'CROSS JOIN' and 'Just describing two tables with comma.' It is useful concept as a tips of a practical programming skill. This concept was referred from THIS ARTICLE on 'SAS 備忘録 (Japanese Blog).'
PROGRAM
--------------------------------------
DATA ID ;
DO ID=1 TO 3 ;
OUTPUT;
END ;
RUN ;
DATA WEEK ;
DO WEEK=1 TO 10 BY 2 ;
OUTPUT ;
END ;
RUN ;
***********************************************************
METHOD 1
***********************************************************;
PROC SQL ;
CREATE TABLE DATA AS
SELECT ID, WEEK
FROM ID, WEEK
;
QUIT ;
***********************************************************
METHOD 2
***********************************************************;
PROC SQL ;
CREATE TABLE DATA AS
SELECT ID, WEEK
FROM ID CROSS JOIN WEEK
;
QUIT ;
PROC PRINT; RUN;
--------------------------------------
OUTPUT (Three ID includes all week )
--------------------------------------
Reference: SAS 備忘録
Updated on Jan 19, 2017.
--------------------------------------
Reference: SAS 備忘録
Updated on Jan 19, 2017.
Post a Comment
別ページに移動します