BookmarkSubscribeRSS Feed

SAS Certified Advanced Programmer 덤프 풀이 95-97

Started ‎06-29-2020 by
Modified ‎06-29-2020 by
Views 375

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

[ONE]

NUM    COUNTRY

-------------------------

1           CANADA

2           FRANCE

3           GERMANY

4           BELGIUM

5           JAPAN

 

[TWO]

NUM          CITY

--------------------------

3                BERLIN

5                TOKYO

 

The following SAS program is submitted:

proc sql;       

select country from one

           where not exists (select * from two where one.num = two.num);  

quit;

 

 

Which one of the following reports is generated?

  1. COUNTRY

        GERMANY JAPAN

     

      b.COUNTRY

          FRANCE BELGIUM

 

       c.COUNTRY

          CANADA FRANCE BELGIUM

 

       d.COUNTRY

          CANADA FRANCE GERMANY

 

[정답] C

[풀이]

sql에서 exists는 서브쿼리로 해당 컬럼의 값의 존재 유무만 체크합니다.

그래서 one테이블의 num (0nenum) two테이블의 num이 같은 것을 참값을 갖게 합니다.

그래서 num 35를 제외한 1,2,4 country canada, france, belgium이 답이 됩니다.

 

 

 

96. Given the SAS data sets ONE and TWO:

ONE                TWO

ID  NAME        ID  SALARY

-------------       -------------

112 Smith         243 150000

243 Wei            355  45000

457 Jones          523  75000

 

The following SAS program is submitted:

data combine;

      merge one two;

      by id;

run;

1.png 

 

Which SQL procedure program produces the same results?

 

[정답] A

proc sql;

create table combine as

select coalesce(one.id, two.id) as id,

name,

salary

from one full join two

on one.id = two.id;

quit;

 

[풀이]

[Data combine]

Merge는 단순 가로대응결합으로 data set의 공통변수의 값을 기준으로 행 병합을 합니다.

각 입력 데이터세트는 BY문장의 변수를 기준으로 정렬합니다.

 

[PROC SQL]

CREATE TABLE을 통해 COMBINE DATA SET을 만듭니다.

SELECT: 결과값에 지정한 변수만 가져오는 함수입니다.

COALESCE(expr1, expr2,…): 해당 컬럼들 중에 서 NULL이 아닌 첫번째 값을 반환하는 함수입니다.

ONE DATA에서 ID TWO DATQ에서의 NULL이 아닌 값을 반환합니다. (ID)

FULL JOIN: 테이블의 합집합으로 모든 데이터를 읽어 JOIN하여 결과를 생성합니다.

+ON절을 이용한 조인: 임의의 조인 조건을 지정하는 방법

 

97. The SAS data set One consists of 5 million observations and has 25 variables. Which one of the following SAS programs 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은 작아지는것이다.

 

Version history
Last update:
‎06-29-2020 12:07 PM
Updated by:
Contributors

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

Article Labels
Article Tags