How many observation are in EMPLSAL dataset
data emplsal;
merge employee (in=ine) salary(in=ins);
by name;
if ine and ins;
run;
Choices are
A. 4
B. 3
c. 2
D. 1
EMPLOYEE | SALARY | ||
NAME | AGE | NAME | SALARY |
Bruce | 30 | Bruce | 40000 |
Dan | 35 | Bruce | 35000 |
| | Dan | 37000 |
| | Dan | . |
Answer is A. 4
ReplyDeletewhat if it is:
Deletedata work.empsalary;
merge work.empployee(in=inemp)
work.salary(in = insal);
byname;
if inemp OR insal; // OR instead of AN
run;
In this example, Same. 4 obs
DeleteBruce 30 40000
ReplyDeleteBruce 30 35000
Dan 35 37000
Dan 35 .
data employee;
ReplyDeleteinput name $ salary;
datalines;
Bruce 40000
Bruce 35000
Dan 37000
Dan .
;
run;
data salary;
input name $ age;
datalines;
Bruce 30
Dan 35
;
run;
data emplsal;
merge employee (in=ine) salary(in=ins);
by name;
if ine=0 and ins=0;
run;
proc print data=emplsal;
run;
(if ine=0 and ins=0 )should be changed to (if ine and ins)
Deletewhy you have to insert this statement? Do we needed to run? you are just confusing us. And you want us to fail in first shot?
ReplyDeleteif ine=0 and ins=0;
yeah that above first person is really confusing us.Please use some sense before you post anything or just know what you are posting!
ReplyDeleteAnswer is A (4)
ReplyDeletemerge employee (in=ine) salary(in=ins);
ReplyDeletei dont understand this statement man :(
please help any one?
Unlike most variables, IN= variables are temporary, existing only during the current DATA step. SAS gives the IN= variables a value of 0 or 1. A value of 1 means that data set did contribute to the current observation, and a value of 0 means the data set did not contribute.
ReplyDeleteIn above question, DAN and BRUCE are included in both data set so condition of [if ine and ins;] is true so output will be 4 obs.
Unknown,
DeleteI still don't quite understand why the correct answer is 4 obs (although I know 4 is the right answer). It seems to me that when SAS reads the last two lines in the data sets, EMPLOYEE does not contain any values for name or age, so INE should = 0 then and the condition would fail to hold, in which case no observations would be written for the last two data lines. Can you please explain why my thinking is incorrect here?
Thanks
Consider this:
Deletedata work.ds1;
merge work.ds2 (in=X) work.ds3 (in=Y);
by id;
1. When in=X and in=Y --> Exact merge. The data set is appended without any condition.
2. Only in=X --> Left inner merge. All the observations in ds2 and those common to ds2 and ds3 are merged. Rest are ignored.
3. Only in=Y ---> Right inner merge. All the observations in ds3 and those common to ds2 and ds3 are merged. Rest are ignored.
4. in=0 and in = Y -->Right outer merge. Only the observations in ds3 are merged.
5. in = X and in=0 --> Left outer merge. Only the observations on d2 are merged.
Hope this helps :)
In this question, the type of the merge is exact merge, since in=ine and in=ins. We do not check any conditions i.e. we do not bother what observations are common to work.ds2 and work.ds3. We simply merge all the observations from both the datasets and write it to ds1.
Deletenice explanation...thank you
Deleteif ine and ins;
Deleterun;
this is a condition for inner join, where observations in both dataset must be common, it checks condition.
This comment has been removed by the author.
ReplyDeletethanks for the explanation Kruti
ReplyDeleteA
ReplyDeleteThe Answer is A
ReplyDeleteFor SAS certification latest and exact exam questions contact us at completeexamcollection@gmail.com.
ReplyDeleteRefer our blog for more details http://completeexamcollection.blogspot.in
A
ReplyDelete