SAS Advanced programming 정리- PROC SQL (4)

Hoya Jaeho Lee·2022년 4월 8일
0

SAS Advanced programming

목록 보기
4/17

Chapter 4 - Combining Tables Vertically Using PROC SQL

정리 후 중요 내용 및 헷갈리는 거 반복 학습할 부분:
intersect all, intersect corr 부분과 outer union의 corr
차이를 잘 구분할 것!!!

Set operators



PROC SQL eliminates duplicate (nonunique) rows in the tables.
PROC SQL: 중첩된 행은 무조건 삭제해줌:)

Using the EXCEPT Operator Alone

코드 설명:
중첩된 거 제거 후, except 구문 그대로

Using the Keyword ALL with the EXCEPT Operator

코드 설명:
except all은 중첩 제거 안하고 그대로 남기고 나서 except 적용

Using the Keyword CORR with the EXCEPT Operator

-> 다소 헷갈려했던 개념이어서 유의있게 볼 것!!!
CORR 이 있을 땐 양쪽 테이블에서 겹치는 col만 확인:)

코드 설명:
corr의 옵션 보면,
일단 중복 행 제거 후
one, two 데이터 셋에서 겹치는 X 모두 삭제

Using the Keywords ALL and CORR with the EXCEPT Operator

ALL과 CORR이 같이 쓰이면 좀 다른데 위랑 구분 잘할 것:)

코드 설명:
all이 있다는 것은 일단 중복 열 제거를 하지 않고,
오로지 x에만 집중해서 보면,
첫번째 열은 제거 2,3 도 제거하고
x에만 해당하는 값만 나옴:)

Using the Keyword ALL with the INTERSECT Operator


Using the UNION Set Operator



코드 설명:
union all은 중복 고려 하지 않고 모두 표기


코드 설명:
union corr은 일단 중복 제거 후에 union에 해당하는 x값만


코드 설명:
union all corr은 중복 고려안하고 union 전체에 해당하는 x값만
주의할 것은 intersect all corr과 다름 (구분 잘할 것!!!)

Using the OUTER UNION Set Operator


코드 설명:
outer union corr의 경우 기존의 case랑 다름!
양쪽 테이블의 모두 컬럼을 명시하되 겹치는 칼럼인 x의 경우는 하나만 명시

Outer union/ SAS data set programming


결국 똑같은 결과 나옴!!
outer union corr이어서 x는 하나만 나오는 거 확인!

profile
Biostatistics researcher Github: https://github.com/hoyajhl

0개의 댓글