16. Which of the following statement(s) in the DATASETS procedure alters the name of a SAS data set stored in a SAS data library?
A. RENAME statement only
B. CHANGE statement only
C. MODIFY and RENAME statements
D. MODIFY and CHANGE statements
정답 : B
해설 : 오답률이 높은 문제입니다. 확실히 구분하시기 바랍니다.
REAME - 변수 이름 바꾸는 기능
CHANGE - 데이터 셋 이름 바꾸는 기능
17. Given the following SAS statement:
%let idcode = Prod567;
Which one of the following statements stores the value 567 in the macro variable CODENUM?
A. %let codenum = substr(&idcode, length(&idcode)-2);
B. %let codenum = substr(&idcode, length(&idcode)-3);
C. %let codenum = %substr(&idcode, %length(&idcode)-2);
D. %let codenum = %substr(&idcode, %length(&idcode)-3);
정답 : C
해설 : %SUBSTR 함수의 기능을 묻는 문제입니다. %substr(A,B,C) 형태로 나타나는 이 함수는 A 문자열을, B번째 자리수부터, C개만큼의 문자를 읽는 것입니다. 즉, %substr(X,2,3)은 변수 X에서 두번째 자리부터 문자열을 읽고, 문자 세 개만 읽는 뜻입니다. 만약 C를 나타내는 파라미터가 없으면 끝까지 읽게 되겠지요. %length(&idcode)-2 가 뜻하는 것은 끝에서 앞으로 두 자리 만큼을 의미합니다.
여기서 -3이 아니라 -2인 이유는, length 값에 의한 포인터가 끝 자리를 가르키고 있기 때문에 Length-1이면 Prod567에서 6을 가르키고, -2이면 5를 가르키게 됩니다. 그러므로 정답은 5에서부터 끝까지 읽는 C가 됩니다.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.