data STOCK;
INPUT COM_CODE $ 8. TYPE $ 8.;
CARDS;
C000001 A
C000002 A
C000002 B
C000003 A
C000003 B
;RUN;
PROC SORT DATA=STOCK;
BY COM_CODE TYPE ;
RUN;
DATA X1;
SET STOCK;
IF FIRST.COM_CODE;
BY COM_CODE;
RUN;
PROC SQL;
CREATE TABLE X2 AS SELECT A.COM_CODE , A.TYPE , B.TYPE AS TYPE2 FROM X1 A LEFT JOIN STOCK B
ON A.COM_CODE=B.COM_CODE AND B.TYPE NE A.TYPE;
|