SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 61


Given the SAS data set QTR 1_REVENUE: 

destination revenue

YYZ 53634 

FRA 62129 

FRA 75962 

RDU 76254
YYZ 82174

The following SAS program is submitted:


proc sort data = qtr1_revenue;
by destination descending revenue; 

run;


What is the first observation in the output data set?


A. destination revenue 

     FRA 62129 

B. destination revenue 

     FRA 75962 

C. destination revenue 

     YYZ 53634 

D. destination revenue 

     YYZ 82174


정렬을 하려고 하는데요. by 이하를 보면, by destination descending revenue;  destination에 대한 변수로 오름차순으로, revenue에 대한 변수로는 내림차순으로 하려고 합니다. 


그러니까 destination에 대해 앞에 아무런 단어가 없으니 default값으로 오름차순이고요. 

revenue에 대해 앞에 descending이 있으니 내림차순이란 뜻입니다. 


Answer: B 



반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 60


The following SAS program is submitted: 


data test;
infile 'file specification';
input name $ amount@@;

run; 


Which of the following is true?

A. Two @@ together are the same as one c.
B. Two @@ hold the data records until the bottom of the DATA step.
C. Two @@ hold the raw data record across iterations of the DATA step.
D. Two @@ are invalid syntax and will cause the program to fail to execute.


input을 통해 name 문자형 변수, amount 숫자형 변수를 만들려고 합니다. 이때 @@ 역할을 묻는 문제입니다. @@ 는 observations을 줄줄이 읽는 기능인데요. 


예를들어 observatiosns이

1, 2, 3, 4, 5, 6, 7, 8, 9, 10 이렇게 되어있으면 


변수 X, Y에 넣을때 @@를 넣어줘야 

X Y

1 2

3 4

5 6

.. 이런식으로 넣게 됩니다. 


만약 @@가 없다면?

1, 2, 3, 4, 5, 6, 7, 8, 9, 10 를 하나의 


X Y

1 2 만 읽고 나머지 3부터는 읽혀지지 않습니다. 

그래서 @@ 넣어서, 알아서 데이타를 줄줄줄 읽어오되 변수에 맞춰서 넣는 기능을 하고 있습니다. 


Answer: C 



반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 59

Given the contents of the raw data file EMPLOYEE: 

----|----10----|----20----|----30

Alan          19/2/2004 ACCT

Rob            22/5/2004 MKTG

MaryJane       14/3/2004 EDUC


The following SAS program is submitted:

data emps;

infile'employee';
input@1 name$
@15 date <insert INFORMAT here> @25 department$;
run;


Which INFORMAT correctly completes the program?


A. date9.
B. ddmmyyyy9. 

C. ddmmyy10. 

D. ddmmyyyy10.


emps라는 데이타를 만들때, input을 이용해서 name, date, deparment 변수를 만들고 있습니다. 


@1 쭉 불러서 name에 넣고 

@15 부터 date로 

@25 부터 department 넣어줍니다. 


이때 informat을 이용하는데요. 이는 데이터를 불러올때 format을 바꿀때 사용합니다.


답은 C. ddmmyy10. 경우 1960년 1월 1이 defalut year cut-off으로 며칠 지났는지 나오게 됩니다. 




Answer: C 




반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 58


The following SAS program is submitted: 

data work.total;

set work.salary(keep = department wagerate); 

by department;
if first.department
then payroll = 0;
payroll + wagerate;
if last.department;
run;


The SAS data set named WORKSALARY contains 10 observations for each department, and is currently ordered by DEPARTMENT.

Which statement is true?


A. The BY statement in the DATA step causes a syntax error. 

B. The statement payroll +wagerate; in the DATA step causes a syntax error.
C. The values of the variable PAYROLL represent the total for each department in the WORK.SALARY data set.
D. The values of the variable PAYROLL represent a total for all values of WAGERATE in the WORKSALARY data set.



WORKSALARY는 각 부사별로 10개의 observations이 있습니다. 그리고 이 데이타는 부서, department 정렬되어있고요. 


work.total이라는 데이터를 만들려고 합니다. keep을 사용해서 department, wagerate라는 변수를 가져오고 있습니다. 그리고 department로 by로 정렬해주고요. 이렇게 오름차순으로 되어있는데 다시 by department; 라고 선언을 하면  if first.department  & if last.department 가 생기게됩니다. 


간단하게 말해서 department의 변수 안에서 여러 부서가 계속 반복적으로 나오잖아요. 이때 첫번째로 나오는 부서와 마지막으로 나오는 부서를 표시해주는겁니다. 물론 이건 결과값으로 나오지 않습니다.


각 부서별로 payroll을 계산하기 위해서, 해당부서의 첫번쨰로 나오는 값부터 마지막까지 나오는 값까지 계산해야하니까 이걸 if first.department, if last.department를 사용해서 어느게 첫번째/마지막 오는지 지정해주는거예요.


if first.department
then payroll = 0;
payroll + wagerate;

이 내용을 살펴보면, 해당부서의 첫번째 observation이면 payroll이란 변수를 만들고 이 초기값을 0 으로 지정해줍니다. 그리고 payroll + wagerate 그러니까 그 해당부서의 첫번째 obervation부터 그 같은 해당부서의 마지막 observation인 wagerate이 누적되어서 payroll 변수에 들어가게 됩니다.


마지막줄, if last.department; 보면 이 말은 해당부서의 마지막 observation이냐?라는 말이고 그렇다면 얘를 결과값으로 즉 output으로 보여주라는 얘기니까 wagerate 값도 보여지게 되겠네요. 



답은 payroll은 각 work.salary데이터셋의 각 department 총 합을 가지게 됩니다. 



Answer: C 


반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 57

Given the SAS data set PERM.STUDENTS:

PERM.STUDENTS NAME AGE --------- ------- 

Alfred 14
Alice 13
Barbara 13

Carol 14

The following SAS program is submitted: 

libname perm 'SAS data library';
data students;
set perm.students;
file 'file specification';
put name $ age; 

< insert statement here> 

run;


The following double-spaced file is desired as output 

Alfred 14
Alice 13
Barbara 13

Carol 14


Which statement completes the program and creates the desired file?

A. put
B. put/;
C. double;
D. put _null_;



set PERM.STUDENTS 즉, SAS 데이터가 perm이라는 라이브러리에 student라는 이름으로 저장되어있습니다. 이때 NAME과 AGE라는 변수를 가지고 있고요. 


students라는 데이타를 만들려고 하는데요. 이 perm 라이브러리에 있는 students 파일을 불러옵니다. 이렇게 만든 students 파일을 file 'file specification'; 라는 명령어로 파일을 넣으려고 하고요. put을 이용해서 name $ age 변수를 유지하려는데 어떤 명령을 넣으면 보기처럼 결과물을 가질 수 있을지 물어보는 문제입니다. 


결과물보면 double-spaced 파일로 지정하고 싶은것 같은데요. 


A. PUT  한칸씩 행을 벌려줍니다. 

B. PUT/; 두칸씩 행을 벌려줍니다. double-spaced가 아니라 triple-spaced가 됩니다. 

C. double; 에러가 발생하고요. 

D. PUT_NULL_ double-spaced이긴 하지만 벌린 행에 .(period)를 넣어줍니다. 


만약 < > 사이에 아무런 옵션도 넣지 않으면, 행과 행 사이 space 없게 됩니다. 



Answer: A 


반응형

+ Recent posts