Chapter 1. Performing Queries using PROC SQL 퀴즈 및 문제풀이



1. Which of the clauses in the PROC SQL program below is written incorrectly?

proc sql;
    select style sqfeet bedrooms

from choice.houses

where sqfeet ge 800;

    a. SELECT

    b. FROM

    c. WHERE

    d. both a and c



    어디가 잘못되었는지 찾는 문제인데요. 

    답은 a. SELECT입니다. SELECT에서 만들고자하는 테이블의 열을 지정해줘야하는데, 이때 스페이스로 (blank) 구분되는게 아니라 comma(,)로 열을 구분합니다. 




    2. How many statements does the program below contain?

    proc sql;

    select grapes,oranges,

       grapes + oranges as sumsales 

    from sales.produce

    order by sumsales;

    a. two 

    b. three 

    c. four 

    d. five



    몇개의 statements가 있는지 찾는 문제입니다. 두개의 statements가 있고요. 하나는 PROC SQL, 다른 하나는 SELECT 입니다. SELECT 명령어에는 3개의 절이 있네요.  




    3. Complete the following PROC SQL query to select the columns Address and SqFeet from the table List.Size and to select Price from the table List.Price. (Only the Address column appears in both tables.)


    proc sql; 

    _____________

    where size.address = price.address; 

    from list.size,list.price;


      a. select address,sqfeet,price

      b. select size.address,sqfeet,price

      c. select price.address,sqfeet,price

      d. either b or c



      PROC SQL의 query를 완성하라는 질문인데요. Address와 SqFeet의 열을 Size라는 테이블에서 불러오고, Price를 Price라는 테이블에서 불러오려고 합니다. 이때 Address의 열은 두개의 테이블에 있다고 합니다. 먼저 두개의 테이블에 같이 있는 공동 변수를 먼저 지정해줘야하겠죠. Select 를 사용해서 address를 먼저 설정해줘야하니 a는 아니고요. adress변수를 size테이블에서 불러와야하니까 size.(period)address 라고 적어줘야해서 답은 b 입니다. 



    4. Which of the clauses below correctly sorts rows by the values of the columns Price and SqFeet?

    a. order price, sqfeet 

    b. order by price,sqfeet 

    c. sort by price sqfeet 

    d. sort price sqfeet



    sort 정렬 방법에 대한 질문입니다. Price와 SqFeeet의 변수를 기준으로 졍렬을 하려고 하는데요. SORT BY 구문을 사용하면 됩니다. 한개 이상의 변수를 , 콤마 넣으면 되어서 답은 b!! 




    5. Which clause below specifies that the two tables Produce and Hardware be queried? Both tables are located in a library to which the libref Sales has been assigned.

    a. select sales.produce sales.hardware 

    b. from sales.produce sales.hardware 

    c. from sales.produce,sales.hardware 

    d. where sales.produce, sales.hardware



    두개의 Produce와 Hardware 테이블을 불러오려고 하는데요. 이때 얘네들이 Sales라는 라이브러리에 있다고 합니다. 불러오려고 할때 FROM을 이용하죠. 라이브러리이름.테이블이름, 라이브러리이름.테이블이름 이렇게 쓰면 됩니다. 그래서 답은 c. 




    6. Complete the SELECT clause below to create a new column named Profit by subtracting the values of the column Cost from those of the column Price.


    select fruit,cost,price, 

    ________________ 

a. Profit=price-cost
b. price-cost as Profit 

c. profit=price-cost
d. Profit as price-cost 



명령어를 완성하는건데요. 새로운 열, Profit을 만들려고하는데 이때 값을 Cost열의 값과 Price라는 값의 차이를 넣어주려고 합니다. Select 구문 아래에 만들어줘야하고요. 이때 새로운 변수를 생성하려면 as 를 사용해서 (필수는 아니고요) Profit 이라고 새 변수이름을 적어주면 됩니다.  그래서 답은 b!! 




#SAS 자격증, SAS advanced, SAS Advanced Programming, SAS Prep Guide, SAS 문제풀이

반응형

+ Recent posts