The following SAS program is submitted:
libname sasdata 'SAS-data-library';
data test;
set sasdata.chemists (keep = job_code);
if job_code = 'chem3'
then description = 'Senior Chemist';
run;
The variable JOB_CODE is a character variable with a length of 6 bytes.
Which one of the following is the length of the variable DESCRIPTION in the output data set?
A. 6 bytes
B. 8 bytes
C. 14 bytes
D. 200 bytes
Click Comment link to get answer
'C'
ReplyDeleteC
ReplyDeleteAnswer is B.
ReplyDeletePlease give some explanations.
Thanks.
My email is xurrnju@gmail.com
Thanks for the explanation of your answer. Yours are the most helpful comments!
DeleteLength of a variable is assigned during first assignement, in this case
ReplyDeletedescription = "Senior Chemist" which is 14 character long, so the new variable description will have lenght of 14. So answer is C. Hope this helps.
"Senior Chemist"
Deletehere is 13 character
if the space counts, will be 14?
If you assume 'chem3' is in the sasdata. chemist
ReplyDeleteAnd the job_code with a lenght of 6 is not like
' Chem3' Or 'CHEM3' the answer C is right.
You can see a example of the ...
ReplyDeleteThe following SAS program is submitted:
libname sasdata ‘SAS-data-library’;
data test;
set sasdata.chemists;
if jobcode = ‘chem3’
then description = ‘Senior Chemist’;
else description = ‘Unknown’;
run;
A value for the variable JOBCODE is listed below:
JOBCODE
CHEM3
Which one of the following values does the variable DESCRIPTION contain?
A. chem3
B. Unknown
C. Senior Chemist
D. ‘ ‘(missing character value)
Answer: B
PLZ EXP IT
DeleteAnswer : C
ReplyDeleteUse proc contents data=test;
to check the variables and attributes.
according the conditions and answers given below its 14
ReplyDeletedata test;
ReplyDeletedescription = 'Senior Chemist';
vlen = vlength(description);
run;
Variable Length is 14
Answer is C
SAS character variables store data as one character per byte. Can be use 1 to 32767 bytes length.
ReplyDeleteC
ReplyDeleteAnswer is C
ReplyDeleteWhat we know from the Program
a) The Variable is created through Assignment Statement
b) And it is a Character Literal (enclosed in ' ')
SAS default behavior for Character literals created through Assignment statement is : Length =Length of first Literal encountered.
Had it been a Numeric Variable created through assignment statement , Length = Default 8 if not explicitly defined elsewhere in program.
Hope it helps.
C
ReplyDelete"Senior Chemist"
THERE ARE 14 WITH SPACE ACCOUNT
C
ReplyDeleteC
ReplyDelete