BookmarkSubscribeRSS Feed

[SAS Programming]SAS Certified Advanced Programmer 덤프3 풀이 38 - 40

Started ‎11-30-2020 by
Modified ‎11-30-2020 by
Views 509

 

 

38. The following SAS program is submitted: 

 

%macro execute;
<insert statement here> 
    proc print data = sasuser.houses;
    run;
%end;
%mend;

 

Which of the following completes the above program so that it executes on Tuesday?

A. %if   &sysday    =    Tuesday  %then %do;
B. %if   &sysday    = ‘ Tuesday' %then %do;
C. %if “&sysday” =     Tuesday  %then %do;
D. %if ‘&sysday’ = ‘ Tuesday' %then %do;

 

[정답]A

[풀이]

매크로 변수이름에는 '&'가 붙고, 매크로 이름에는 '%'가 붙습니다.

 

 

*조건식을 가진 매크로

%IF 조건문 %THEN 실행문;

-> 조건문에는 quotation marks가 필요 없습니다.

 

*SYSDAY: 자동 매크로 변수로 session 시작 요일

 

 

 

39. Which one of the following statements is true regarding a SAS DATA step view?

A. It allows write capabilities.
B. It contains global statements.
C. It contains data and a descriptor portion.
D. It contains a partially compiled DATA step.

 

[정답]D

 

[풀이]

SAS DATA Views는 데이터는 저장되지 않지만 저장된 프로그램을 담고 있는 데이터 파일의 일반화된 database개념으로 SAS코드가 저장됩니다.

 

실제의 데이터는 담고 있지 않지만,  I/O를 줄이고, 데이터 공간을 줄이고 실제 시간을 줄여줍니다.

+ sas data file에는 데이터가 저장되어 있으며, 데이터 뷰에는 구조가 저장되어 있습니다.

 

 *VIew 구조

data dept.a / view = dept.a;

   .... more SAS statements...

run;

 

 

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

 

[ONE Data]


OBSCOMMONX
1A10
2A13
3A14
4B9
5C8
6C14

  

[TWO]

OBSCOMMONX
1A1
2A3
3B4
4B2
5C5

 

The following SAS DATA step is submitted: 

data combine;
    merge one two;
    by common;
run;

Which one of the following represents the data values stored in data set COMBINE?

 

 

A.

obscommonXY
1A101
2A133
3A143
4B94
5B92
6C85
C145

 

B.

obscommonXY
1A101
2A133
3B94
4C85

 

C.

XcommonXY
1A101
2A133
3B144
4B92
5C85

 

D.

XcommonXY
1A101
2A131
3A141
4A103
5A133
6A143
7B94
8B92
9C85
10C145

 

 

 

[정답] A

[풀이]

merge문은 둘 이상의 sas 자료들을 관측별로 병합하여 새로운 sas자료를 만듭니다.

병합하는 자료들에 공통적인 변수가 있으면 이 공통변수를 BY문장에서 지정할 수 있습니다.

 

*MERGE SYNTAX

 

DATA sas-data-set;
    MERGE sas-data-set(S); /*먼저 나오는 table이 master테이블이고, 그 다음 나오는 테이블이 transaction 테이블입니다. */
    BY variable(s); /*정렬 되어야 합니다.*/
RUN;

 

*one-to-many, many-to-many, non-matches가 있다.

 

> one-to-many(일대다결합)

master table에서 unique하게 나타나틑 BY variable값과 Transaction table에서 여러 번 나타나는 BY variable값이 matching될 경우입니다.

 

> many-to-many merging

master table과 transaction table에서 여러 번 나타나는 BY variable값이 matching될 경우.

 

> Merging with non-matches

master table과 transaction table에서 BY variable 값의 일부 또는 전부가 non-matching되는 경우.

 

 BY common으로 1:1매칭이 가능하지 않으면, 가장 최근에 1:1매칭에 성공한(=윗값)값을 복사합니다.

 

위 문제는 many-to-many merging으로 BY common에서 A값이 있는 one table과 two table을 살펴보면,

 

one table에는 

1 A 10 

2 A 13 

3 A 14

 

two table에는

1 A 1

2 A 3

이 있습니다.

 

merge는 단순 가로결합으로 결과는

1 A 10 1

2 A 13 3

3 A 14 3(윗값 복사)이 됩니다.

그러므로, 매칭이 안되는 값은 바로 윗행을 복사합니다.

Version history
Last update:
‎11-30-2020 06:15 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