Sas Crambible 3

Adios_Hosang·2022년 9월 28일
0

SAS crambible

목록 보기
3/20

Q3.

The following SAS program is submitted:
data work.accounting;
set work.dept1 work.dept2;
jobcode= 'FA1';
length jobcode $ 8;
run;

A character variable named JOBCODE is contained in both the WORK.DEPT1 and WORK.DEPT2 SAS data sets.
The variable JOBCODE has a length of 5 in the WORK.DEPT1 data set and a length of 7 in the WORK.DEPT2 data set. What is the length of the variable JOBCODE in the output data set?

A. 3
B. 5
C. 7
D. 8

이 문제는 set 구문과 length 구문과의 관계성을 묻는 문제입니다.

length 변수 $8;과 같은 구문을 작성할 경우 해당 변수는 문자열 길이 8로 지정한다는 의미입니다. 만약, 문자열이 아닐 경우 length 변수 8;과 같이 작성하면 됩니다.

그러나, set 구문이 들어갈 경우 주의할 점이 있습니다.
set 구문이 있을 때는 data구문과 set 구문 사이에 length 구문을 작성해야지 원하는 length가 지정이 됩니다.

그렇지 않을 경우는 set 구문에 가장 먼저 선언된 데이터셋의 길이를 따르게 됩니다.

해당 문제에선 length 구문이 data구문과 set구문 사이에 오지 않았습니다.
따라서, 가장 먼저 오는 데이터셋인 work.dept1의 길이를 따르므로 정답은 C(길이 5)가 됩니다.

profile
IT를 시작하고자 합니다

0개의 댓글