The following SAS program is submitted:
data work.empsalary;
set work.people (in = inemp)
work.money (in = insal);
if insal and inemp;
run;
The SAS data set WORK.PEOPLE has 5 observations, and the data set WORK.MONEY has 7 observations.
How many observations will the data set WORK.EMPSALARY contain?
A. 0
B. 5
C. 7
D. 12
Click Comment link to get answer
'A'
ReplyDeleteA
ReplyDeleteThis comment has been removed by the author.
DeleteA. 0
ReplyDeleteWhy is it A?
ReplyDeleteRun the code:
Deletedata work.people;
input names $ ;
datalines;
Ramesh
Suresh
;
run;
data work.money;
input names $ ;
datalines;
Ramesh
Suresh
;
run;
data work.empsalary;
set work.people (in = inemp)
work.money (in = insal);
inemp_value = inemp;
insal_value = insal;
run;
proc print data = work.empsalary;
Obs names inemp_value insal_value
1 Ramesh 1 0
2 Suresh 1 0
3 Ramesh 0 1
4 Suresh 0 1
if you see output the condition "if insal and inemp; " will never satisfy. Hence 0 observation.
Because in it a set statement not merge, so only inemp or insal can be true at a time.
ReplyDeleteYes, like SAScert said, the answer is '0' observations because the statement 'merge' is not used. At this case, you are either inemp or insal, but not both.
ReplyDeletetrue...0 is the ans..
ReplyDeleteso if the statement was re-written from an 'AND' to an 'OR' (if insal OR inemp), would this be allowable for SET statement?
ReplyDeleteyes you can change 'AND' to 'OR' but it will be same as regular set statment, so there is no need for OR.
ReplyDeleteIn 'SET', only one table is contributing in any one observation of resulting dataset therefore only one 'in=' variable can be true for such observation.
ReplyDeleteA:0
ReplyDeleteจีคลับ
goldenslot
A
ReplyDeleteThis Is Really Useful And Nices Information. เสือมังกรมือถือ
ReplyDeleteThis are such great articles. เสือมังกรมือถือ This articles can help you to make some new ideas.
https://soccersurfer98.hatenablog.com/entry/2020/09/02/132139?_ga=2.193217001.552343305.1598844608-1286484823.1596077192 I appreciate for reading my blogs.
Very Helpful Articles. เสือมังกรมือถือ It might help you. เสือมังกรมือถือ Thanks For Sharing
ReplyDeleteเสือมังกรมือถือ Thank you very much.