Data Science/SAS

[SAS BASE] CramBible Q#18 문제풀이 | VAR | SUM

오기오기 2024. 9. 28. 19:47
728x90
반응형

QUESTION NO: 18

 

The SAS data set PETS is sorted by the variables TYPE and BREED. The following SAS program is submitted:

proc print data = pets;
  var type breed;
  sum number;
run;

 

A. The SUM statement produces only a grand total of NUMBER.

B. The SUM statement produces only subtotals of NUMBER for each value of TYPE.

C. The SUM statement produces both a grand total of NUMBER and subtotals of NUMBER for each value of TYPE.

D. Nothing is produced by the SUM statement; the program fails to execute

 


문제풀이

 

proc print data = pets;
  var type breed;
  sum number;
run;

 

  • VAR 문으로 TYPE과 BREED 변수를 출력하도록 지정하였습니다.
  • SUM 문으로 변수 NUMBER의 합계를 계산하고 출력합니다.

 

 

  • PROC PRINT의 기본 기능:
    • SUM 문은 지정된 변수에 대해 **전체 합계(grand total)**를 계산합니다.
    • 만약 데이터셋이 BY 문을 사용하여 특정 변수로 그룹핑되어 있으면, 각 그룹별로 **부분 합계(subtotal)**도 계산됩니다.
    • BY 문이 PROC PRINT와 함께 사용되었다면, 각 BY 그룹에 대해 부분 합계(subtotal)도 출력됩니다.
  • 이 문제에서는 BY 문이 없으므로, SUM 문은 전체 합계(grand total)만 계산합니다.

정답 : A

 

728x90
반응형