SAS Certified Advanced Programmer 덤프 풀이 80-82
options yearcutoff = 1950;
%macro y2kopt(date);
%if &date >= 14610 %then %do;
options yearcutoff = 2000;
%end;
%else %do;
options yearcutoff = 1900;
%end;
%mend;
data _null_ ;
date = "01jan2000"d;
call symput("date", left(date));
run;
%y2kopt(&date)
The SAS date for January 1, 2000 is 14610 and the SAS system option for YEARCUTOFF is set to 1920 prior to submitting the above program.
Which one of the following is the value of YEARCUTOFF when the macro finishes execution?
A. 1900
B. 1920
C. 1950
D. 2000
[정답] D
[풀이]
yearcutoff : 두자리 연도의 범위를 설정 (default는 1920)
Macro 조건문 %IF %THEN
[문법]
January 1, 2000는 14610되어있습니다. 그래서 매크로 조건문에 맞게 YEARCUTOFF 는 2000으로 실행됩니다.
ONE
LEVEL AGE
------------
1 10
2 20
3 20
2 10
1 10
2 30
3 10
2 20
3 30
1 10
The following SAS program is submitted:
proc sql;
select level, max(age) as MAX
from one
group by
level having max(age) > (select avg(age) from one);
quit;
Which one of the following reports is generated?
A
LEVEL AGE
-----------
2 20
3 20
B
LEVEL AGE
-----------
2 30
3 30
C
LEVEL AGE
-----------
2 20
3 30
D
LEVEL AGE
-----------
2 30
3 30
[정답] D
[풀이]
Proc sql문을 사용해서 sql 문법이해가 필요합니다.
Select: 결과 테이블에 원하는 변수만 선택합니다. As 문을 사용해서 max(age)를 MAX라는 변수를 만들었습니다.
From: 참조하는 테이블
Group by: level 변수를 기준으로 같은 데이터 값끼리 그룹화합니다.
Having: 요약된 테이블에 조건을 거는 함수입니다.
LEVEL |
AVG(AGE) |
MAX(AGE) |
1 |
10 |
10 |
2 |
20 |
30 |
3 |
20 |
30 |
AVG(AGE)보다 MAX(AGE)가 큰 조건(GROUP BY)은 LEVEL 2,3입니다.
A. The KEEP statement is available in both the DATA and the PROC steps.
B. The KEEP statement selects the variables read from the input data set(s).
C. The KEEP statement applies to all data sets created within the same DATA step.
D. The KEEP statement applies only to the first data set created within the same DATA step if more than one data set is created.
[정답] C
[풀이]
keep문은 결과 데이터셋에서 남기고 싶은 변수를 선택하는 함수입니다.
문법은 ‘KEEP Variable-list;’입니다. Variable-list에 넣은 변수를 제외하고는 제거합니다.
KEEP문을 첫 문장에 사용해도 keep문장의 효과를 얻을 수 있습니다.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.