BookmarkSubscribeRSS Feed

[SAS Programming]SAS Certified Advanced Programmer 덤프3 풀이 23-25

Started ‎10-18-2020 by
Modified ‎10-18-2020 by
Views 483

23.

The SAS data set ONE consists of five million observations and has 25 variables.

Which one of the following SAS programs successfully creates three new variables TOTREV, TOTCOST, and PROFIT and requires the least CPU time to be processed?

a.

data two;
    set one;
    totrev sum(price * quantity);
    totcost = sum(fixed,variable);
    profit = sum(totrev,totcost); 
    if totrev> 1000; 
run;

 b.

data two;
    set one;
    totrev = sum(price * quantity);
    if totrev> 1000;
        totcost = sum(fixed,variable);
    profit = sum(totrev,totcost); 
run;

 c.

data two;
    set one; 
    totrev = sum(price * quantity);
    where totrev> 1000;
    totcost = sum(fixed,variable);
    profit = sum(totrev,totcost);
run;

 d.

data two;
    set one; where totrev> 1000;
    totrev = sum(price * quantity);
    totcost = sum(fixed,variable);
    profit = sum(totrev,totcost);
run; 

 정답: B

[풀이]

if문은 모든 데이터를 평가 한 다음 올바른 데이터를 선택하는게 아니라 correct 데이터를 선택해 효율적으로 cpu time은 작아지는것입니다.

a는 if 조건에 결과가 없는 올바르지 않은 코드입니다.

 

24. Given the following SAS data set ONE:

ONE 
COUNTRY CITY   VISIT
USA    BOSTON 10
UK      LONDON 5
USA    DALLAS 10
UK      MARLOW 10
USA    BOSTON 20
UK      LONDON 15
USA    DALLAS 10

The following SAS program is submitted:

proc sql;
    select country, city, sum(visit) as TOTAL
        from one group by country, city order by country, total desc;
quit;

Which one of the following reports is generated?

A.

COUNTRY CITY   TOTAL 
UK      MARLOW 10
UK      LONDON 20
USA     BOSTON 50
USA     DALLAS 20

B.

COUNTRY CITY   TOTAL
UK      LONDON 20
UK      MARLOW 10
USA     BOSTON 50
USA     DALLAS 20

C.

COUNTRY CITY   TOTAL
USA     BOSTON 50

D.

COUNTRY CITY   TOTAL
UK      MARLOW 10
UK      LONDON 20
USA     DALLAS 20
USA     BOSTON 50 

[정답] B

[풀이]

proc sql;
    select country, city, sum(visit) as TOTAL
        from one group by country, city order by country, total desc;
quit;

 group by xxx : 칼럼을 xxx 기준으로 나눠서 연산을 수행.

 order by xxx : 칼럼을 xxx를 오름차순으로 데이터를 정렬합니다.

 

*여기서 B의 USA- BOSTON-30으로 바꿔야 합니다.

 

25. Given the following SAS data sets ONE and TWO:

ONE 
NUM CHAR1 
1   A
2   B
4   D

TWO 
NUM CHAR2
2   X
3   Y
5   V

The following SAS program is submitted creating the output table THREE:

 

 

data three;
    set one two;
run;

 

THREE

NUM CHAR1 CHAR2

1         A

2         B

4         D

2                       X

3                       Y

5                       V

 

Which one of the following SQL programs creates an equivalent SAS data set THREE?

A.

proc sql;

create table three as select * from one outer union corr select * from two; quit; 

B.

proc sql;

create table three as select * from one outer union select * from two; quit; 

C.

proc sql;

create table three as select * from one outer union select * quit;

D.

proc sql; create table three as select * from one union corr select * from two; quit; 

 

[정답] A
[풀이]
outer union에 관한 문제입니다.
Set Operators(집합연산자)로 최종 결과 set을 생성하기 위해 두 개의 쿼리에 대해 중간 결과를 set을 사용합니다.
집합연산자는 총 4개입니다.
  • UNION - 두 개의 중간 결과 set의 고유한 행만을 반환
  • OUTER UNION - 두개의 중간 결과 set의 모든 행과 열을 반환
  • EXCEPT - 첫 번째 쿼리 중 두번째 쿼리에 없는 고유한 행을 반환
  • INTERSECT - 두번째 쿼리 중 첫번째 쿼리에 없는 고유한 행을 반환

*Set Operator Code

SELECT

UNION | OUTER JOIN | EXCEPT | INTERSECT

 

OUTER UNION에서 CORR MODIFIER

두 개의 SET에서 중복되는 변수는 하나의 열로 통합합니다.

Version history
Last update:
‎10-18-2020 10:48 AM
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