ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 61

The following SAS program is submitted:
data work.staff;
JobCategory = 'FA';
JobLevel = '1';
JobCategory = JobCategory || JobLevel;
run;
Which one of the following is the value of the variable JOBCATEGORY in the output data set?
A. FA
B. FA1
C. FA 1
D. ' ' (missing character value)
Click Comment link to get answer

31 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Ya ..its A
    length of JobCategory already set to 2 by the first assignment statement

    ReplyDelete
    Replies
    1. it is not because of length man;
      change the 4th line to
      JobCategory1=JobCategory || JobLevel;

      Delete
    2. Anonymous10:35 AM

      no because you are using the same name for the variable the Jobcategory variable is automatically assigned to 2. So yo have to manually set the length to 3 or 4.

      Delete
  3. Huh? I dont understand what this line is supposed to mean:

    JobCategory = JobCategory JobLevel;

    But when u try to run it, the program stops working because of syntax errors.

    ReplyDelete
  4. There is a typo, it should be
    JobCategory = JobCategory || JobLevel;
    I will update the questions. Thanks for pointing it out.

    ReplyDelete
  5. Anonymous2:30 PM

    Thanks Jungs you have the write explaination

    Answer is A

    ReplyDelete
  6. Anonymous1:46 AM

    Answer is A

    reason:

    jobcategory='FA';

    after this jobcategory variable's length is two bytes,it can hold only two bytes.

    Eventhough there is no mistake in the step

    jobcategory=jobcategory//joblevel;

    jobcategory carries the value FA.

    ReplyDelete
  7. Anonymous2:57 PM

    If they wanted under new variable NewJobCat then it would have
    FA / 1 ( with little distance because it needs trim to stay closer to FA).

    ReplyDelete
    Replies
    1. No, it will output FA1 if store it in new variable. i just run it with new variable and it outputted FA1

      Delete
  8. Ans A:
    behind the scenes:
    1. the PDV writes the variables jobcategory (length 2) joblevel (length 1)with missing values
    2. at the execution jobcategory gets FA and joblevel gets 1
    3. the concatenation overrides the variable jobcategory with FA1 but because the length of that variable is 3, the 1 is excluded.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  9. Anonymous3:48 PM

    data staff;
    length jobcategory $3;
    jobcategory = 'FA';
    joblevel ='1';
    jobcategory = trim(jobcategory) || joblevel;
    *jobcategory = jobcategory || joblevel;
    run;
    if you define the character length; and use trim function you will have FA1 as answer. Otherwise FA (only two character length) seems to be the answer

    ReplyDelete
    Replies
    1. Anonymous2:37 PM

      This is the reasoning I was waiting for..
      Thanks!! :)

      Delete
  10. Ans is A

    Explanation--> Actual value of the variable jobcatogery is FA1 How ever since sas first finds the value of Job category as FA it sets the length to 2 hence 1 is finally discarded from FA1 to make up to a length of 2.

    ReplyDelete
  11. Anonymous3:22 PM

    shouldn't it be a syntax error and henceforth a missing value since JOBCATEGORY is different from jobcategory?

    ReplyDelete
  12. Ans is A try in SAS but if you run this prgm as below with new var added then ans be FA1 but now it is FA as length of var is set to 2 in PDV:
    data work.staff;
    JobCategory = 'FA';
    JobLevel = '1';
    NJobCategory = JobCategory || JobLevel;
    run;

    ReplyDelete
  13. Anonymous11:30 PM

    why is trim function is used when there is no trailing blanks in the above examples?

    ReplyDelete
  14. Good post. I learn something totally new and challenging on blogs I stumble upon on a daily basis. It will always be interesting to read articles from other authors and practice something from their websites...

    Base SAS Training in chennai

    ReplyDelete
  15. Anonymous9:08 PM

    answer is A
    jobcategory=jobcategory//joblevel;

    jobcategory carries the value FA.

    ReplyDelete
  16. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of....
    Aws training chennai | AWS course in chennai
    Rpa training in chennai | RPA training course chennai
    sas training in chennai | sas training class in chennai

    ReplyDelete