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
'B'
ReplyDeleteA. 3
ReplyDeleteObs fname age salary totsal
1 Bruce 30 25000 25000
2 Bruce 30 35000 60000
3 Dan 40 25000 85000
they have asked for variable
DeleteAnswer is B.
DeleteYour example here is clearly showing FOUR variables, not three
This comment has been removed by the author.
DeleteWhen it ask for variables then counts number of columns except obs not rows!
Deleteif work.employee had Dan & his salary info then the Ans wd be B:
ReplyDeleteObs fname age salary totsal
1 Bruce 30 25000 25000
2 Bruce 30 35000 60000
3 Dan 40 . 60000
4 Dan 25000 . 60000
'c' 5
ReplyDeletename age salary totsal
. 37000 37000
Bruce 30 40000 77000
Bruce 30 35000 112000
Dan 35 . 112000
Dan . . 112000
A
ReplyDeleteAnswer is B for sure
ReplyDeleteB
ReplyDeleteB. Also, I'd like to point out that the question is how many VARIABLES are in the output dataset - not observations.
ReplyDeletehaha good point.I did not even realize it' s the # of variables they want.Boy,better focus on the questions more
DeleteCorrect Answer: B
ReplyDeleteThe Variables are: Fname, age, salary and totsal (i.e 4 variables)
Note: Obs will not be counted here
Correct Ans: B
ReplyDeleteYour Right Anonymous ! It's a Kind a dangerous question.
ReplyDeleteThanks !
I still do not see why "A" is the wrong answer.
ReplyDeleteCould 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.
ReplyDeletetotsal is created in the sum statement
Delete"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.
ans is 3 or 4 ?
ReplyDeletewhat is important is
the last obs Dan 25000 belongs to which dataset;
data employee;
ReplyDeleteinput 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
i ran your code, and there are 4 variables. not sure why you say it's A.
DeleteIt Looks like that the persons are Mixing Vaiables with observation.
DeleteCorrect Answer is 'B'
Rows=Observations=Records
Columns=Variables=Fields
GOOD Luck Guys@!
Definitely B. ur gonna end up with 4 variables.
ReplyDeletefname salary age and totsal....
Defiantly sure, can you write your reasons.
ReplyDeletePlease; 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.
ReplyDeleteSAS 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.
Frnds ans is 'B' they have not ask observation its variable asked so once again go through question.
ReplyDeleteThe answer should be c) 5: Obs,fname,age,salary and totsalary.
DeleteObs is an observation??? i never knew it
DeleteThis is a little tricky. You have to read the question closely. It is asking:
Delete"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.
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.
ReplyDeleteAnswer is B. Just run this
ReplyDeletedata 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;
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 ????
ReplyDeletelike your confidence :D
DeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
DeleteB
ReplyDeleteB
ReplyDeleteNOTE: The data set WORK.EMPDATA has 3 observations and 4 variables.
ReplyDelete