BookmarkSubscribeRSS Feed

[SAS Programming]SAS Certified Advanced Programmer 덤프3 풀이 26-28

Started ‎10-23-2020 by
Modified ‎10-23-2020 by
Views 386

26. Which one of the following automatic SAS macro variables contains the return code from a previously executed step?

A. &RC
B. &ERR
C. &SYSRC
D. &SYSERR

 

[정답]D

[풀이]

&SYSERR은 SAS STATEMENT가 실행됨에 따라 자동적으로 변하는 매크로 변수 중 하나로

SAS DATA 또는 PROC STEP의 return code입니다.

에러가 발생하면 1 , 에러가 없으면 0을 반환합니다.

 

 

27.The SAS data set ONE has a variable X on which an index has been created. The data sets ONE and THREE are sorted by X. Which one of the following SAS programs uses the index to select observations from the data set ONE?

A.

data two;
    set three;
    set one key = X;
run;

 

B.

data two;
    set three key = X; 
    set one;
run;

 

C.

data two;
    set one;
    set three key = X;
run;

 

D.

 

data two;
    set three;
    set one (key = X);
run; 

[정답] A

[풀이]

 SAS INDEX문으로도 접근을 할 수 있지만 SET구문 규칙을 묻는 문제로도 볼 수 있습니다. (SET문의 KEY 옵션)

DATA단락은 메인 데이터셋 three를 읽은 후 참조 데이터 셋인 one을 읽는다.

그리고, X변수를 토대로 직접 접근합니다.

 

+) Index?

대량의 SAS 데이터셋은 순차적으로 자료를 읽습니다. (sequential access)

순차적으로 자료를 읽는 과정을 피하고자 특정 관측치를 직접 찾기 위해서 인덱스를 사용합니다.(direct access)

*INDEX의 옵션들

WHERE statemet: 데이터의 한 부분집합에서 더 빠르고 효율적인 접근을 제공합니다. (=작은 subset에 더 빠르게 접근하는 경우)

BY: SORT 절차를 사용하지 않고도인덱스는 인덱스 순서로 관측치들을 돌려줍니다.

SET 문 & MODIFY 문:  ‘KEY = ‘ 옵션 DATA 단락에서 인덱스를 지정하여 한 데이터 파일에서 특정한 관측들을 검색할 수 있게 해줍니다.

 

28.Given the following SAS data set ONE:

ONE 
REP   AREA  COST
SMITH NORTH 100
SMITH SOUTH 200
JONES EAST  100
SMITH NORTH 300
JONES WEST  100
JONES NORTH 200
JONES NORTH 400
SMITH NORTH 400
JONES WEST  100
JONES WEST  300

The following SAS program is submitted:

proc sql;
    select rep, area, count(*) as TOTAL from one group by rep, area; 
quit;

 

Which one of the following reports is generated?

 

A.

REP   AREA  COUNT
JONES EAST  100
JONES NORTH 600
JONES WEST  500
SMITH NORTH 800
SMITH SOUTH 200

B.

REP   AREA  TOTAL
JONES EAST  100
JONES NORTH 600
JONES WEST  500
SMITH NORTH 800 
SMITH SOUTH 200

C.

REP   AREA  TOTAL
JONES EAST  1
JONES NORTH 2
JONES WEST  3
SMITH NORTH 3

D.

REP       AREA       TOTAL
JONES   EAST          1
JONES   NORTH        2
JONES   WEST          3
SMITH    NORTH        3
SMITH    SOUTH         1

[정답]D
[풀이]
<pre style="color: rgb(0, 0, 0);">proc sql;
select rep, area, count(*) as TOTAL from one group by rep, area;
quit;
group by xxx : xxx를 기준으로 나눠서 연산을 수행.
rep과 area 2개 모두 만족하는 기준으로 나눠서 연산을 수행합니다
rep area total
----------------------
smith north 100,300,400 -> count(개수 세기) 3
smith south 200
jones east 100
jones west 100 100 300 -> count해서 3
jones north 200 400 -> count해서 2

Version history
Last update:
‎10-23-2020 08:37 PM
Updated by:
Contributors

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

Article Labels
Article Tags