ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 54

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

18 comments:

  1. Answer is B.

    Please give some explanations.

    Thanks.

    My email is xurrnju@gmail.com

    ReplyDelete
    Replies
    1. Anonymous12:29 PM

      Thanks for the explanation of your answer. Yours are the most helpful comments!

      Delete
  2. Length of a variable is assigned during first assignement, in this case
    description = "Senior Chemist" which is 14 character long, so the new variable description will have lenght of 14. So answer is C. Hope this helps.

    ReplyDelete
    Replies
    1. "Senior Chemist"
      here is 13 character
      if the space counts, will be 14?

      Delete
  3. Anonymous11:29 AM

    If you assume 'chem3' is in the sasdata. chemist

    And the job_code with a lenght of 6 is not like
    ' Chem3' Or 'CHEM3' the answer C is right.

    ReplyDelete
  4. Anonymous11:34 AM

    You can see a example of the ...

    The 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

    ReplyDelete
  5. Anonymous2:54 PM

    Answer : C

    Use proc contents data=test;
    to check the variables and attributes.

    ReplyDelete
  6. Anonymous2:43 AM

    according the conditions and answers given below its 14

    ReplyDelete
  7. Anonymous12:19 AM

    data test;
    description = 'Senior Chemist';
    vlen = vlength(description);
    run;

    Variable Length is 14

    Answer is C

    ReplyDelete
  8. Anonymous5:08 AM

    SAS character variables store data as one character per byte. Can be use 1 to 32767 bytes length.

    ReplyDelete
  9. Answer is C
    What 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.

    ReplyDelete
  10. Anonymous9:25 PM

    C
    "Senior Chemist"
    THERE ARE 14 WITH SPACE ACCOUNT

    ReplyDelete