SAS Tech & Tip

BookmarkSubscribeRSS Feed

SAS Certified Advanced Programmer 덤프2 풀이 10-12

Started ‎07-10-2020 by
Modified ‎07-10-2020 by
Views 440

10.

 

1.png

 

Given the SAS data set SAUSER.HIGWAY:

 

%macro highway; 

proc sql noprint; 

 %let numgrp = 6; 

 select distinct status 

 into :group1 - :group&numgrp 

 from sasuser.highway; 

 quit; 

 %do i = 1 %to &numgrp;

 proc print data = sasuser.highway; 

 where status = "&&group&i" ; 

 run; 

 %end; 

%mend; 

%highway 

 

How many reports are produced? 

A. 0 

B. 2 

C. 5

D. 6

 

[정답]​ ​B

[풀이]

%macro highway; 

proc sql noprint;  /*출력창으로 출력하지 않고, 새로운 데이터셋에 결과를 기록하고 싶을 경우 noprint 옵션을 사용*/

 %let numgrp = 6; /*매크로numgrp가 6으로 출력되는 매크로 생성*/

 select distinct status  /*select COUNT(xxx) INTO yyy : 칼럼 xxx의 개수를 매크로 변수 yyy의 결과값으로 반환한다. */

 into :group1 - :group&numgrp /*select distinct로 중복없이 추출합니다.(status변수를 중복없이 추출) */

 from sasuser.highway; 

 quit; 

 %do i = 1 %to &numgrp;

 proc print data = sasuser.highway; 

 where status = "&&group&i" ; 

 run; 

 %end; 

%mend; 

%highway 

 

group1은 not그룹의 리포트, group2는 serious그룹의 리포트로 총 2개의 리포트를 생성합니다.

 

 

11. The following SAS program is submitted:

%let dept=prod; /*매크로 dept가 prod로 출력되는 매크로를 생성*/

%let prod=merchandise; /*매크로 prod가merchandise로 출력되는 매크로 생성*/

 

 

The following message is written to the SAS log:

The value is "merchandise"

 

Which SAS System option writes this message to the SAS log?

 

 

A. %put the value is "&&&dept"; B. %put the value is ""&&&dept""; C. %put the value is '"'&&&&dept'"'; D. %put the value is %quote(&&&dept);

*ppt에 A,B,C,D가 틀리게 표기되어 있습니다.

 

[정답] A

[풀이]

&의 참조 개수에 따른 참조 위치를 묻는 문제로 ‘Forward Re Scan Rule’이라고 합니다. 

한번 더 스캔한다는 규칙으로 두 번 참조시 매크로 프로세서는 && 두 개를 & 한 개로 인식하기 때문에, 두 번 참조를 위해선 &&& 이렇게 세 개로 써주셔야 합니다.

 

 규칙은 왼쪽에서 오른쪽으로 가고괄호를 사용하여 표시하면 쉽게   있습니다.

(&&)(&dept)

(&)(&dept)

&&dept

(&&)dept

&dept /*매크로dept를 출력합니다.*/

 

 

 

 

12.The SAS data set WORK.TEMPDATA contains the variables FMTNAME, START and

LABEL and it consists of 10 observations.

 

The following SAS program is submitted:

 

Proc format cntlin=work.tempdata;

Run;

 

What is the result of submitting the FORMAT procedure step?

 

A. It uses the WORK.TEMPDATA SAS data set as input to create the format

B. All formats created will be stored in two WORK.TEMPDATA SAS data set

C. An ERROR message is written to the SAS log because the program is incomplete

D. NO formats are created in this step

 

[정답] A

[풀이]

sas의 내장된 형식(format)이 사용자가 원하는 결과를 만들어내지 못할 수 있습니다.

PROC FORMAT은 이러한 상황에서 자신만의 형식(format)을 만들어 사용할 수 있습니다.

출력형식을 적절하게 적용하면, 출력결과를 보기 좋게 만들어 출력결과의 질을 높일 수 있습니다.

 

CNTLIN옵션은 사용하면 데이터를 직접적으로 만들거나 VALUE statement를 사용하지 않고도 코드를 직접 생성할 수 있습니다.

그러므로, 정답은 A가 됩니다.

Version history
Last update:
‎07-10-2020 10:58 PM
Updated by:
Contributors

sas-innovate-white.png

Join us for our biggest event of the year!

Four days of inspiring keynotes, product reveals, hands-on learning opportunities, deep-dive demos, and peer-led breakouts. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

Article Labels
Article Tags