ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 102

The SAS data sets WORK.EMPLOYEE and WORK.SALARY are listed below:
WORK.EMPLOYEE WORK.SALARY
fname age fname salary
Bruce 30 Bruce 25000
Dan 40 Bruce 35000
Dan 25000
The following SAS program is submitted:
data work.empdata;
merge work.employee
work.salary;
by fname;
totsal + salary;
run;
How many variables are output to the WORK.EMPDATA data set?
A. 3
B. 4
C. 5
D. No variables are output to the data set as the program fails to execute due to errors.
Click Comment link to get answer

39 comments:

  1. Anonymous8:18 AM

    A. 3


    Obs fname age salary totsal

    1 Bruce 30 25000 25000
    2 Bruce 30 35000 60000
    3 Dan 40 25000 85000

    ReplyDelete
    Replies
    1. they have asked for variable

      Delete
    2. Anonymous2:40 PM

      Answer is B.

      Your example here is clearly showing FOUR variables, not three

      Delete
    3. This comment has been removed by the author.

      Delete
    4. When it ask for variables then counts number of columns except obs not rows!

      Delete
  2. Anonymous9:15 AM

    if work.employee had Dan & his salary info then the Ans wd be B:

    Obs fname age salary totsal
    1 Bruce 30 25000 25000
    2 Bruce 30 35000 60000
    3 Dan 40 . 60000
    4 Dan 25000 . 60000

    ReplyDelete
  3. Anonymous11:39 AM

    'c' 5
    name age salary totsal
    . 37000 37000
    Bruce 30 40000 77000
    Bruce 30 35000 112000
    Dan 35 . 112000
    Dan . . 112000

    ReplyDelete
  4. Anonymous4:23 PM

    Answer is B for sure

    ReplyDelete
  5. Anonymous6:08 AM

    B. Also, I'd like to point out that the question is how many VARIABLES are in the output dataset - not observations.

    ReplyDelete
    Replies
    1. Anonymous5:37 PM

      haha good point.I did not even realize it' s the # of variables they want.Boy,better focus on the questions more

      Delete
  6. Anonymous1:29 AM

    Correct Answer: B
    The Variables are: Fname, age, salary and totsal (i.e 4 variables)
    Note: Obs will not be counted here

    ReplyDelete
  7. Anonymous4:14 AM

    Correct Ans: B

    ReplyDelete
  8. Your Right Anonymous ! It's a Kind a dangerous question.

    Thanks !

    ReplyDelete
  9. I still do not see why "A" is the wrong answer.

    ReplyDelete
  10. Anonymous2:30 PM

    Could someone explain how 'totsal' is known by SAS to be like a counter variable in the merged dataset not having been referenced in either of the 2 data sets? Thanks.

    ReplyDelete
    Replies
    1. Jenine2:46 PM

      totsal is created in the sum statement

      "totsal+salary"

      If you see this format of sum, with no equals sign, no parentheses and no keyword, that is your clue that it is a SUM STATEMENT.

      The processing of a sum statement goes like this:

      SAS creates the variable on the left hand side of the plus sign, and initializes it to zero.

      Then it adds whatever is on the right hand side of the plus sign. Note that it treats missing values as zero, just like the sum function.

      Then it retains the resulting value as it goes through to the next iteration.

      That is why you use SUM STATEMENT as an accumulating variable.

      It is kind of tricky because the sum statement is really not showing you much information about what it is doing, but if you look for those clues I listed above you'll not miss it.

      You can think of it as a shorthand way of writing:

      retain totsal 0;
      totsal = sum(totsal, salary);

      which is an equivalent way of doing the same thing.

      Delete
  11. Anonymous2:41 PM

    ans is 3 or 4 ?
    what is important is
    the last obs Dan 25000 belongs to which dataset;

    ReplyDelete
  12. Anonymous4:34 PM

    data employee;
    input fname $ age;
    datalines;
    Bruce 30
    Dan 40
    ;
    run;

    data salary;
    input fname $ salary;
    datalines;
    Bruce 25000
    Bruce 35000
    Dan 25000
    ;
    run;

    data work.empdata;
    merge work.employee
    work.salary;
    by fname;
    totsal + salary;
    run;

    Ans:A

    ReplyDelete
    Replies
    1. Anonymous1:29 PM

      i ran your code, and there are 4 variables. not sure why you say it's A.

      Delete
    2. Anonymous6:24 PM

      It Looks like that the persons are Mixing Vaiables with observation.
      Correct Answer is 'B'
      Rows=Observations=Records
      Columns=Variables=Fields
      GOOD Luck Guys@!

      Delete
  13. Definitely B. ur gonna end up with 4 variables.
    fname salary age and totsal....

    ReplyDelete
  14. Anonymous4:19 PM

    Defiantly sure, can you write your reasons.

    ReplyDelete
  15. Anonymous11:18 AM

    Please; Do not act like a child and make yourself foolish. Someone forgot to count variables and still says the answer is A. Or my mistakenly you wrote A.
    SAS user please do not get confused with observation and variable.
    If you do in in exam, ask yourself how many times you going to sit.

    Sorry to make harsh comment.

    ReplyDelete
  16. Anonymous1:35 AM

    Frnds ans is 'B' they have not ask observation its variable asked so once again go through question.

    ReplyDelete
    Replies
    1. Anonymous2:10 AM

      The answer should be c) 5: Obs,fname,age,salary and totsalary.

      Delete
    2. Obs is an observation??? i never knew it

      Delete
    3. Jenine2:53 PM

      This is a little tricky. You have to read the question closely. It is asking:

      "How many variables are OUTPUT"

      So yes, technically the OBS column is listing the values of a variable (not an observation, I think you meant to say variable anith). In fact, it is listing the values of the SAS system variable _N_.

      However, _N_ is a SAS system variable and WILL NOT BE OUTPUT to the final dataset.

      So it does not get counted in the number of variables output, which include only fname, age, salary and totsal.

      Four variables are output.

      Delete
  17. Anonymous3:49 PM

    These idiots cannot count. They list 4 variables then insist there are 3 variables. If you can't count or you don't know the difference between a variable and an observation you need to think about another career.

    ReplyDelete
  18. Anonymous7:08 PM

    Answer is B. Just run this
    data EMPLOYEE;
    input fname $ age;
    datalines;
    Bruce 30
    Dan 40
    Dan 25000
    ;
    run;

    data salary;
    input fname $ salary;
    datalines;
    Bruce 25000
    Bruce 35000
    ;
    run;

    data work.empdata;
    merge work.employee work.salary;
    by fname;
    totsal + salary;
    run;

    ReplyDelete
  19. Anonymous10:12 AM

    SAS mentions I need a minimum of 70% correct to pass the exam, so is it ok if I mark 70% of the questions correct & 30% wrong, will I still be able to pass the test ????

    ReplyDelete
  20. This comment has been removed by the author.

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

      Delete
  21. Anonymous6:41 PM

    NOTE: The data set WORK.EMPDATA has 3 observations and 4 variables.

    ReplyDelete