The following SAS program is submitted:
proc sort data=work.employee;
by descending fname;
proc sort data=work.salary;
by descending fname;
data work.empdata;
merge work.employee
work.salary;
by fname;
run;
Which one of the following statements explains why the program failed execution?
A. The SORT procedures contain invalid syntax.
B. The merged data sets are not permanent SAS data sets.
C. The data sets were not merged in the order by which they were sorted.
D. The RUN statements were omitted after each of the SORT procedures.
Click Comment link to get answer
C
ReplyDeleteC. The data sets were not merged in the order by which they were sorted.
ReplyDeleteIs it necessory to merge two or more data sets in a say order as they sorted?
ReplyDeleteYES , It is a must
Delete?
ReplyDeleteThe two datasets were sorted pre merge statement in the question, all by decending of fname. I would say if it is not working, it would be fname may not exist for one of the dataset. A is my answer.
D
ReplyDeleteanns
ReplyDeleteCorrect Answer: C
ReplyDeleteYou should have the DESCENDING option in the BY statement in both the PROC SORT steps and the DATA STEP. If you omit the DESCENDING option in the DATA STEP, you denerate error messages about improperly sorted BY Variable.
Correct Answer: C
ReplyDelete100% correct
You need to have the DESCENDING option in the BY statements in both the PROC SORT steps and the DATA step. If you omit the DESCENDING option in the DATA step in the BY statement, you generate error messages about improperly sorted BY Variables.
d
ReplyDeleteso how do we know what the absolute correct answer is?
ReplyDeletePROC SORT DATA=states;
ReplyDeleteBY state_name;
PROC SORT DATA=vehicles;
BY state_name;
DATA widedata;
MERGE states vehicles;
BY state_name;
RUN;
C is tehe good answer
Thank you for the examples, they are great...this is a bit off the point but if someone could clarify -
ReplyDeletemerge work.employee
work.salary;
by fname;
is the new data set work empdata going to merge the two datasets and sort them in ascending order now by fname? I thought the reason for going through the proc sort by descending fname for each separate data set as to avoid the default sort?
I believe it's B and D.
ReplyDeleteA not, syntax is correct
C not, the datasets weren't merged because of the missing descending at the by statement of the datastep (all by statements must have the same order)
B because employee and salary are in work and
D if run is missing, the next data or proc step will determine the end of the previous step and run will be omitted
ERROR: BY variables are not properly sorted on data set WORK.AIR.
ReplyDeleteDATE=01DEC1960 AMOUNT=. AIR=432 FIRST.DATE=1 LAST.DATE=1 _ERROR_=1 _N_=1
The above is the error when I ran the code..so its D
Sorry but your error message would indicate the correct answer is C
Delete(which is certainly is!)
data banks;
ReplyDeleteinput num;
datalines;
1
2
3
4
5
;
run;
data banks2;
input num x $;
datalines;
5 a
4 b
3 c
2 d
1 e
;
run;
proc sort data=banks;
by descending num;
run;
proc sort data=banks2;
by descending num;
run;
data banks3;
merge banks banks2;
by num;
run;
log
ERROR: BY variables are not properly sorted on data set WORK.BANKS.
num=5 x=a FIRST.num=1 LAST.num=1 _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 2 observations read from the data set WORK.BANKS.
NOTE: There were 2 observations read from the data set WORK.BANKS2.
WARNING: The data set WORK.BANKS3 may be incomplete. When this step was stopped there were 0
observations and 2 variables
ans is c as it merges when u insert descending in the data step
you really dont need to input this into SAS. data step needs to have the by statement in the same exact manner as it was sorted out. in this case you have to use descending.
ReplyDeleteans is c
answer is definitely C. u dont need run at the end and it needs to be sorted out in the same order.
ReplyDeleteFolks , Even the data has in shorted form and sorted properly , give the same error.
ReplyDeleteThat means we are missing something in the data statements or proc statement.
Look at this data set.
data bank1;
input num y $;
datalines;
1 t
2 u
3 v
;
run;
data banks2;
input num x $;
datalines;
1 a
2 b
3 c
;
run;
proc sort data=bank1;
by descending num;
run;
proc sort data=banks2;
by descending num;
run;
data banks3;
merge bank1 banks2;
by num;
run;
proc print data=bank3;
run;
I got the same error. So what is the reason it is giving us that error message,
W need to find out that then we will be ready for the exam. We are getting answer just running a sas program. But in exam we have to use our head and the logic. How we going to get it and what is it, giving us error message.
In merge if you choose to sort by descending then you must use descending with merge statement otherwise it will not merge because of reason ( C ).
ReplyDeleteIt does not matter if you sort by ascending order.
The 2 proc sorts arrange in desc order...but the merge is in asc order...so the merge will fail ANS C
ReplyDeleteBase SAS prep Guide:
ReplyDelete"General form, basic DATA step for match-merging:
DATA output-SAS-data-set;
MERGE SAS-data-set-1 SAS-data-set-2;
BY variable(s);
RUN;
DESCENDING indicates that the input data sets are sorted in descending order (largest
to smallest numerically, or reverse alphabetical for character variables) by the variable that is
specified.
Each input data set in the MERGE statement must be sorted in order of the values of the BY variable(s), or it must have an appropriate index. Each BY
variable must have the same type in all data sets to be merged."
So answer is C.
typo correction :
ReplyDeleteBy descending variable(s).
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 ????
ReplyDeletethank you for all the explanations
ReplyDeletea
ReplyDeleteFor latest and updated SAS certification dumps in PDF format contact us at completeexamcollection@gmail.com
ReplyDeleteRefer our blog for more details http://completeexamcollection.blogspot.in/2015/12/sas-certification-dumps.html
C is 100 % right Answer.
ReplyDeleteBecause In Sort procedure data sorted in descending order . but descending keyword is missing while Merging the Data in By statement.
Right Code :
data work.empdata;
merge work.employee
work.salary;
by descending fname;
run;
THanks
ReplyDelete