Data Analysis/SAS EG

[SAS] 단일 IF

AubreyJeong 2021. 6. 11. 10:00

단일 If = Subsetting If

 

조건이 참이면 현재 실행을 계속하고(implicit output 문장 포함),

거짓이면 해당 obs에 대해 더 이상 다른 문장을 실행하지 않고 (삭제drop하고) 즉시 DATA step의 처음으로 돌아간다. 

(관측 값을 PDV(Program Data Vector)로 읽은 후 조건을 테스트한다)

 

If without then is a subsetting statement, and all records not satisfying the condition are dropped.

"Continues processing only those observations that meet the condition of the specified expression"

 

IF AGE="10" 은  ‘AGE가 10인 행들을 선택한다.’는 의미!  (+ 그렇지 않은 행들을 전부 버린다.) 

 

DATA sampletest;
	set sample1;
    IF name; /* sample1 이라는 데이터셋에서 name이라는 변수가 결측값이 아닌 것만 선.택.*/
run;

 

 

(추가 설명 from stackoverflow)

https://stackoverflow.com/questions/23718029/if-then-vs-if-in-sas

Specifically, subsetting if terminates the current iteration of the data step loop and returns to the top of the data step; similar to if (...) then return. This is important because anything that is after the subsetting if that is failed does not execute in that row. Subsetting if does prevent the automatic output (as it would prevent the non-automatic output; above) but doesn't affect earlier output statements.

 

 

'Data Analysis > SAS EG' 카테고리의 다른 글

[SAS] PROC DATASETS  (0) 2021.06.16
[SAS] MACRO ① : Macro 사용 목적과 기능  (0) 2021.06.14
[SAS] PUT, INPUT  (0) 2021.06.09
[SAS] Format, Informat  (0) 2021.06.08
[SAS] 레코드, 행의 수 세기  (0) 2021.06.07